Key disable&Gravity Set!

Non-platform specific questions.

Key disable&Gravity Set!

Postby XclusiveGames » Mon Mar 07, 2011 9:07 am

if a actor's key down(up) is set to y = y -9; it should fly when we press the given button.how to disable the key
when it collides with another character ,and the character should have gravity so that it will fall to the ground.any idea! please? :?
Masscreations.
XGames

Under Development
User avatar
XclusiveGames
 
Posts: 35
Joined: Fri Jan 21, 2011 3:30 pm
Score: 4 Give a positive score

Re: Key disable&Gravity Set!

Postby skydereign » Mon Mar 07, 2011 9:14 am

To do that you need a variable. I'd suggest you create a variable that holds the state of the actor (state).
actor -> KeyDown (up, Repeat) -> Script Editor
Code: Select all
if(state==0)
{
    y=y-9;
}


The above says only when state is zero do you have the actor fly. So, if you want to disable the flying ability, set it to 1.
actor -> Collision (otherActor) -> Script Editor
Code: Select all
state=1;


Now flying will be disabled. I assume you want to enable it as soon as you touch back on ground, so in your collision with top side of the ground actor, add this.
Code: Select all
state=0;


This type of variable control will help a lot, when making a game. The idea is pretty simple and very powerful. If you understand this, then you can have many different values for the state variable, and control the actor very precisely.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Key disable&Gravity Set!

Postby XclusiveGames » Mon Mar 07, 2011 9:27 am

Thanks SKI it worked.
:D
Masscreations.
XGames

Under Development
User avatar
XclusiveGames
 
Posts: 35
Joined: Fri Jan 21, 2011 3:30 pm
Score: 4 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest