User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Double Tap (Direction Keys Left and Right)

  1. #1
    Clicker Fusion 2.5
    darkmanx_429's Avatar
    Join Date
    Jun 2010
    Location
    Earth 313
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Double Tap (Direction Keys Left and Right)

    I am trying to use a counter in order to create separate walk and run animations my character for a 2D platformers.

    I am using the keyboard for the control scheme and I want the player to press the left or right arrow to walk and then when pressed again the player will begin to run instead of walk.

    Right now, I made a "Run Counter" and have the it set at the beginning of frame to 0. I want 1 to be set for walking and 2 for running.

    I have it in the event editor so that once the player presses left/right, I compare the counter to a value "Equal to 1" and add 1 to the counter, the player walks. When the player does other actions such as jumping I just set reset the counter to 0 and play the appropriate animation and it all works.

    The problem is what I am having is how to input the arrow controls for a double key press. I tried copying the right and left arrow actions from my walk cycle but that doesn't quite do it. I am a bit confused on what i need to code to proceed.
    Images attachées Images attachées

  2. #2
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    sprykethegame.com
    Posts
    3,210
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    You want to use upon pressing a key rather than repeat while key is pressed. The latter triggers on every single frame, while the former triggers only once per key press. So what's happening now is that when you tap the right arrow, the counter goes up so rapidly that it ends up at neither 1 nor 2. Even if the key is only pressed down for 0.1 seconds, that'll still make the counter go up to 6 (assuming that your game runs at 60 frames per second)

  3. #3
    Clicker Fusion 2.5
    darkmanx_429's Avatar
    Join Date
    Jun 2010
    Location
    Earth 313
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Volnaiskra View Post
    You want to use upon pressing a key rather than repeat while key is pressed. The latter triggers on every single frame, while the former triggers only once per key press. So what's happening now is that when you tap the right arrow, the counter goes up so rapidly that it ends up at neither 1 nor 2. Even if the key is only pressed down for 0.1 seconds, that'll still make the counter go up to 6 (assuming that your game runs at 60 frames per second)
    Dang. I had that thought as well, but wasn't sure.

    I just have the counter set a value once the player hits a key stroke, i.e.
    repeat by pressing the right arrow/set counter to 1 ; counter =1 means to walk
    upon pressing space bar/set counter to 3; counter =3 means to jump
    Once the player lands on the ground the counter resets to 0 which is stop.
    When the player falls I subtract 1 from the counter to play the fall animation..etc.

    I was trying to use value 1 for walk value 2 for run. But I don't know how to basically press right key stroke 1 time for walk/ 2 times for run.

    EDIT: When I use upon instead of repeat my character doesn't move anymore. I should mention I am using the Platform movement object and global object for each of the frames of my game.

  4. #4
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)

    Join Date
    Jun 2006
    Location
    Killeen, TEXAS
    Posts
    1,237
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    you can use "repeat while pressed" & also "press key" alongside each other. * the press key is used for counting your double taps if you do it, otherwise it will move normally.
    if you want to continue using your movement as you are with repeat while left is held etc, you can do that. you will probably need to add a flag to it like ( flag [ double tap ] is OFF ) and you move left.

    now you can put right under it,
    press left - add counter (double tap left), and another double tap right counter for right.
    you can void these if you press any other key - eg; press any key + [negate] repeat pressing left and left double tap counter >0 set it back to zero - and so on.

    if double tap count is 2, then set your double tap flag ON so you normal repeat while pressing left is not active and do your double tap move.

    you need flags to turn on and off your normal move vs double tap move. it sounds a little messy, but its simple once you figure it.
    ------------------------------------------------------------------------------------------------------------------------------------------------
    eg: for moving left.... this is another simple way of doing it. it moves 1 pixel, and double tap moves it 16 * i didnt add in the use flag for this, but if you are doing something completely different for double tap - like an attack or jump etc, you may need the flag to stop its normal move.

  5. #5
    Clicker Fusion 2.5
    darkmanx_429's Avatar
    Join Date
    Jun 2010
    Location
    Earth 313
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by danjo View Post
    you can use "repeat while pressed" & also "press key" alongside each other. * the press key is used for counting your double taps if you do it, otherwise it will move normally.
    if you want to continue using your movement as you are with repeat while left is held etc, you can do that. you will probably need to add a flag to it like ( flag [ double tap ] is OFF ) and you move left.

    now you can put right under it,
    press left - add counter (double tap left), and another double tap right counter for right.
    you can void these if you press any other key - eg; press any key + [negate] repeat pressing left and left double tap counter >0 set it back to zero - and so on.

    if double tap count is 2, then set your double tap flag ON so you normal repeat while pressing left is not active and do your double tap move.

    you need flags to turn on and off your normal move vs double tap move. it sounds a little messy, but its simple once you figure it.
    ------------------------------------------------------------------------------------------------------------------------------------------------
    eg: for moving left.... this is another simple way of doing it. it moves 1 pixel, and double tap moves it 16 * i didnt add in the use flag for this, but if you are doing something completely different for double tap - like an attack or jump etc, you may need the flag to stop its normal move.
    My buddy helped me with this and used 2 alterable values. Once that Initiated the Dash and then a Dash Cooldown. I am going to try it your way to see the difference. Thank you!

  6. #6
    Forum Moderator

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,840
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)

    Use flags

    I agree with Danjo. You need flags to turn on and off your normal move vs double tap move.

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  7. #7
    Clicker Fusion 2.5
    darkmanx_429's Avatar
    Join Date
    Jun 2010
    Location
    Earth 313
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nivram View Post
    I agree with Danjo. You need flags to turn on and off your normal move vs double tap move.

    Marv
    I am still confused on how to input the double tap though versus 1 tap in the editor.

  8. #8
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)

    Join Date
    Jun 2006
    Location
    Killeen, TEXAS
    Posts
    1,237
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    the tap is just a counter; when the counter = 2 ( for 2 taps) - perform your move. otherwise its moves as normal, and the counter will reset every 1 second ( or whatever you want for the speed of doubletap )

  9. #9
    Clicker Fusion 2.5
    darkmanx_429's Avatar
    Join Date
    Jun 2010
    Location
    Earth 313
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by danjo View Post
    the tap is just a counter; when the counter = 2 ( for 2 taps) - perform your move. otherwise its moves as normal, and the counter will reset every 1 second ( or whatever you want for the speed of doubletap )
    Interesting. It didn't think of counters actually being used that way for the game in regards to directional tap. I am going to experiment today with that and get back with you! Thank you.

  10. #10
    Clicker Fusion 2.5
    darkmanx_429's Avatar
    Join Date
    Jun 2010
    Location
    Earth 313
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    EDiT: Figured it out! What I did was I did a key bind to a button, enabled it by using a directional press and then used a new counter to keep track of the directional press in either direction and then just assigned that animation to a new PMO object.

    I then added a timer value to reset the counter for the duration of the sprint animation to cycle through.

    Everything works great!

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Direction Keys don't work in HTML5
    By rc_a in forum HTML5 Export Module 2.5
    Replies: 3
    Last Post: 28th November 2014, 06:28 PM
  2. Use A, W, S, D Keys For Eight Direction Movement
    By drnebula in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 4th June 2010, 11:24 PM
  3. Remap Direction Keys ?
    By SUNCHIRP in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 1st April 2009, 03:17 PM
  4. Possible to remap direction movement to new keys?
    By SUNCHIRP in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 31st March 2009, 10:21 PM
  5. Left and right direction
    By Rabagast in forum File Archive
    Replies: 11
    Last Post: 1st July 2008, 07:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •