Gods Posted December 31, 2014 Share Posted December 31, 2014 I am sure everyone who wanted there HTML5 game to work mobile had this problem. So I have my controls set up as space bar to jump but I want my HTML5 game to work everywhere so I need to change it to mouse/touch. Mouse/touch doesnt have a keycode so whats the most optimal way to do it for this code? Do I need to do mouse and touch separately? if (KEY_STATUS.space && player.dy === 0 && !player.isJumping) { player.isJumping = true; player.dy = player.jumpDy; jumpCounter = 12; assetLoader.sounds.jump.play();}// jump higher if the space bar is continually pressedif (KEY_STATUS.space && jumpCounter) { player.dy = player.jumpDy;}I have read a lot of tutorials on this and it seems like its going to be a lot of code I just want to know what html5 devs do so I dont write bad JS code. Its not a simple KeyCode for mouse or something. So how does this code snippet look like if Jump is set to mouse/touch? Anyone have code they can share? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.