Make your character move in a game is crucial to your game. What the fun, if we can't move or interact with the character in the game. Especially in Role Play Game type, moving character is very important, because thats the only way player interact with the game.
How to Move Object with Keyboard in Flash?
If you want to make your own game with Flash, its very easy to move your character with Keyboard. You only need to follow this easy steps:
- Create New Flash File
- Add Rectangle Graphic or Something, and Convert It to Movie Clip (Select Graphic then Press F8)
- Name it with "BOX", or something else like "RECT", "HERO", or anything else.
- Now click to BOX, then press F9 to open Action Script
- Add this code:
onClipEvent (enterFrame) {
if ((Key.isDown(Key.RIGHT))) {
this._x = 5;
} else if ((Key.isDown(Key.LEFT))) {
this._x -= 5;
}
if ((Key.isDown(Key.DOWN))) {
this._y = 5;
} else if ((Key.isDown(Key.UP))) {
this._y -= 5;
}
}
First, flash will react if one of this key is pressed (UP, DOWN, LEFT, RIGHT). Than flash will move "BOX" with change the X and Y value of the box. Its very easy to understand. If you want to make object move faster, then simply add moving value with greater number.
I hope this will help you.
Keyword (Indonesia) : menggerakkan karakter dengan keyboard di flash game
Image : wasd.co.uk

nice article, btw support & keep write bro :D
ReplyDeletejng lupa baca ini Daun Sirsak Membunuh Sel Kanker
Thanks for comment.
ReplyDeleteLangsung ke TKP nih bro.