Sign in to follow this  
xronn

Spacebar tap function?

Recommended Posts

I'm using the spacebar as shown below -

interactButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);

Then I call it as such - 

if (quest1 == false && interactButton.isDown)

The problem is if you tap the spacebar you hold it down for 3 or 4 milliseconds thus meaning the if statement is run 3 or 4 times, which isn't any good.

If I change it too - 

if (quest1 == false && interactButton.isUp)

Then when I tap the spacebar the whole time it's up after the tap which is until I press it down again it loops through the if statement which isn't any good either. Does Phaser support something like a tap listener so when its down and then up it runs once not 100s of times as it currently does.

Share this post


Link to post
Share on other sites

 

This is basically what I need however it uses the isDown call which is what Im using... Do you know if it solves the issue just by adding time between events, I didn't really want to start adding timed delays between keyboard input.

 

A callback method will work for everyone who uses a key for a single purpose e.g. moving the player up... However my spacebar input is used as an interaction thus requiring it to be used all over my game so it can't have a single callback. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.