BlaineP16 Posted March 20, 2017 Share Posted March 20, 2017 So to get right to the point. I am having issues with my ship image/sprite and my drawn objects on screen disappearing as soon as I try and addEventListener to code. why does my code essentially break when i add the EventListener? is it not possible to add controls to image or sprite within Html canvas? Ship game code = https://codepen.io/BlaineP16/pen/VpQBZV Quote Link to comment Share on other sites More sharing options...
ProSteveSmith Posted April 4, 2017 Share Posted April 4, 2017 This doesn't look like the full project. It looks like you're missing space.js, and pen.js among other files. Quote Link to comment Share on other sites More sharing options...
Njotrvella Posted April 4, 2017 Share Posted April 4, 2017 Looks like you're doing something based on this tutorial: https://developer.mozilla.org/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript/Paddle_and_keyboard_controls? I guess you forgot to change "paddleWidth" to "ship.width" And your code probably breaks because of typos in your handlers names. They are currently named keyDownHander and keyUpHander. Note the missing l. Also there are probably some issues related to "collision checks". I could be more helpful if you described what kind of behaviour you're trying to achieve. And yeah, would be nice to look at full project. 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.