To stop a x x moving script.

You must understand the Game Editor concepts, before post here.

To stop a x x moving script.

Postby Diana Kennedy » Tue May 30, 2006 4:44 pm

Inaugurating this Forum - I hope with no too stupid question. I am relating to my other problem, and this may be the key:

I use the following script in the draw actor event to make an actor move:

Code: Select all
x = x - 5;


or:

Code: Select all
x = x + 5;


Now how can I make stop him?

I did this: On a timer event I put:

Code: Select all
x = x - 0;


But it did not work.
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby plinydogg » Tue May 30, 2006 5:26 pm

Diana,

I'm not sure exactly what your needs are, but couldn't you

(1) Create a global integer variable called, say, actorCanMove and set it to 0;
(2) In the draw actor event replace x = x - 5 with

if(actorCanMove == 1)
{
x = x-5;
}

(3) When you want the actor to move, set actorCanMove equal to 1; when you want the actor to stop, set actorCanMove equal to 0 again.
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby Diana Kennedy » Tue May 30, 2006 5:53 pm

Hi Plinydog,

Sounds like a good solution. But I am not advanced enough to know the exact steps to do: I created the variable in the global script editor, but how do I set its value to 0 and what would be the exact syntax?
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby BeyondtheTech » Tue May 30, 2006 7:40 pm

Just so you know, standard C syntax like
Code: Select all
x+=5;
is a viable shortcut to
Code: Select all
x=x+5;
in Game Editor. It's easier to type, less prone to typographical error, and may be ever-so-slightly faster in execution.

x-=5; is the same as x=x-5; and so on...
User avatar
BeyondtheTech
 
Posts: 270
Joined: Wed Mar 30, 2005 6:34 am
Location: Edison, NJ
Score: 4 Give a positive score

Postby BeyondtheTech » Tue May 30, 2006 7:43 pm

Another solution is to have the Draw Actor event to have
Code: Select all
x=x+xmovement;
where xmovement is a variable you can set to 5, -5, 0, or whatever you need to. If you want to stop it, set xmovement to 0. If you need to start up again, set the variable as necessary.
User avatar
BeyondtheTech
 
Posts: 270
Joined: Wed Mar 30, 2005 6:34 am
Location: Edison, NJ
Score: 4 Give a positive score

Postby Diana Kennedy » Tue May 30, 2006 8:09 pm

Interesting shortcut thanks. 8)
But I still need to know how to create the variable with the initial setting. I am afraid I don't see clear enough to do this.



[/code]
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby Novice » Tue May 30, 2006 9:45 pm

To add an initial setting to a variable put
Code: Select all
variable=any number;

in a create actor event or any other event that ocurs only once (you don't want them to reset each time the event reocurs :D )
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby Diana Kennedy » Wed May 31, 2006 12:42 am

Thnak you very much! 8)
User avatar
Diana Kennedy
 
Posts: 257
Joined: Wed Dec 07, 2005 12:34 am
Location: France, where Presidents who got shot in Texas do exile ;-)
Score: 0 Give a positive score

Postby sonicfire » Sun Nov 26, 2006 11:07 pm

x = 0 ?
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Postby Game A Gogo » Tue Nov 28, 2006 1:24 am

on create actor insted of draw actor
Code: Select all
xvelocity=1;
and on the timer thing
Code: Select all
xvelocity=0;
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest