Thursday, December 5, 2013

Program first action

Since I've been here since last year, my coding experience is alright, so I went straight to programming the character once I finished it. I got the standard character movements in, so it moves left, right, up, and down, but to add to that, I added a "sprint", where you hold down shift along with any other key. The type of code I used was:

if(Key.isDown(Key.[Any Arrow Key])){
character._x -= [Number]
}

and the sprinting aspect adds more to that number, so it would be like this in the end:

if(Key.isDown(Key.LEFT)){
character._x -= 6
}
if(Key.isDown(Key.SHIFT) and Key.isDown(Key.LEFT)){
character._x -= 10
}

So, this allows the character to move left and sprint left. I also added the code to make the character spin left or right whenever you go that way.

character._xscale = -100

Makes the character look the opposite way than where it is currently facing.

2 comments:

  1. I like how you gave us the code so we could do it ourselves.

    ReplyDelete
  2. its easy all you have to do is find the code on the wiki or from your mini game or what ever

    ReplyDelete