problem in codes

nicoy

  • Posts: 11
can any body give me a sample of two way movement source code??? pls..  ;)

NexusxAlpha

  • Posts: 157
can any body give me a sample of two way movement source code??? pls..  ;)

Do you want source code or the behaviour for 2 way movement?

You can edit the behaviour and go to the tab labelled "Preview code"

« Last Edit: August 29, 2012, 03:49:10 am by NexusxAlpha »

ipe 369

  • Posts: 1001
I don't do actionscript, only java, but i'll write it out in a way you can convert it to blocks:

make 2 events, both key pressed events
make another 2, both key released events
set your controls. Right will be the control to go right (right arrow key, or d, or whatever you want) and left will be the other. Pretty damn self explanetory tbf.

The events will look like this:
When left is pressed
    if (right is not pressed) //This block can be found in input > keyboard
        set xspeed to -speed for self //the set xspeed block is found in actor > motion, the -speed is the speed you want him to travel at. If you want the speed to be 4, set this value to -4
When right is pressed
    same in here but with a positive value for speed
When left is released
    if (right is not pressed)
        set xSpeed to 0 for self;
When right is released
Same here but reversed. The zero is still zero, believe it or not.