-
Game - Character Movement Help
Hi Guys im having problems with the movement with my character, I managed to move my character from left to right, the only problem is when i move my character right / left i make the character inner timeline to go and play a walk frames so it gives an illusion that my character is walking, i got that done even when i press the right /left buttons, but im having a problem when the key is released how do i make my character come to a stand still position.
Note: this game is for a mobile and im using Flash Lite 1.1,
Please help
Regards
Peter
-
Senior Member
if(key to go right is pressed down){
char.gotoAndPlay(walkingframes)
}else if(key to go left is pressed down){
char.gotoAndPlay(walkingframes)
}else{
char.gotoAndStop(standingframe)
}
-
Dear tonypa
Thanx for your reply but the code you written is flash flash 5 and above in Flash Lite 1.1 we dotn have an option to check if a key is pressed on if statements, we can only use it on 'on' statements
Button:
on(keyPress "6"){
your code here
}
if(key.isDown) not supported in flash lite 1.1 got any other suggestions on how i can achievne this,
mind you this is flash 4 syntax
Regards
Peterr
-
Senior Member
yikes, its been too long since I used Flash4.
How about this:
*place Stop() in the first frame of walking animation
*make walk animation loop back from last frame to frame1
*use play() when the key is detected
So if no keys are pressed, it automatically stops in frame1.
hm... should work in Flash4 too, sorry if it doesnt.
-
hey Tonypa,
i dont know if its going to work, but isnt there any way to detect if a keeey is unpressed like we have in flash 6.
Rgds
Peter
-
Senior Member
No, Flash4 doesnt know anything about releseasing keys.
You could set up frame loop (as Flash4 doesnt have enterframe either).
In frame 1 set variable to false:
Set Variable: "pressed" = false
On the buttons set variable to true:
On (Key: a)
Set Variable: "pressed" = true
End On
In frame2 check if variable is true (meaning some button was pressed) or false (meaning none of the buttons were pressed):
If (pressed=true)
trace("key down")
Else
trace("no keys pressed, stop walking")
End If
-
Hey Tonypa Well i tried doing this, it works perfectly, but when a button is not pressed the variable is turned to true, and remains true, so everytime when the condition is check it is always true and does not go back to false. so my character is like walking forever and not stop when the button is not pressed.
Regards
Peter
-
infidel!
try this:
If (pressed=true)
trace("key down")
Else
pressed = false
trace("no keys pressed, stop walking")
End If
-
Senior Member
The idea was that movie should continue looping between frames 1 and 2 and the variable was set back to false in frame 1. I wrote the code in Flash4, there might be some differences with FlashLite, sorry but I have never used FlashLite.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|