A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Game - Character Movement Help

  1. #1
    Junior Member
    Join Date
    Jun 2004
    Location
    None
    Posts
    16

    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
    Peter Franco
    ver.nu

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    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)
    }

  3. #3
    Junior Member
    Join Date
    Jun 2004
    Location
    None
    Posts
    16
    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
    Peter Franco
    ver.nu

  4. #4
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    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.

  5. #5
    Junior Member
    Join Date
    Jun 2004
    Location
    None
    Posts
    16
    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
    Peter Franco
    ver.nu

  6. #6
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    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

  7. #7
    Junior Member
    Join Date
    Jun 2004
    Location
    None
    Posts
    16
    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
    Peter Franco
    ver.nu

  8. #8
    infidel! 0vidiu's Avatar
    Join Date
    Mar 2003
    Location
    ROmania
    Posts
    267
    try this:


    If (pressed=true)
    trace("key down")
    Else
    pressed = false
    trace("no keys pressed, stop walking")
    End If

  9. #9
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center