doenerklaus Posted August 1, 2014 Share Posted August 1, 2014 hey, i am working on a little game with Panda.js. Is there a way to set Player movements to a Sprite?I test this code: var btnright = new game.Sprite('btn.png',576,0); btnright.interactive = true; btnright.mousedown = btnlinks.touchstart = function() { this.player2.jump(); }; this.stage.addChild(btnright); The Sprite is showing, but the Player doesn't jump. I also testet this Code: mousedown: function(event) {this.player2.jump();},If i click on the Screen the Player jump, but i only want that the Player jump if i click on the Sprite. Anyone got an idea? Quote Link to comment Share on other sites More sharing options...
doenerklaus Posted August 5, 2014 Author Share Posted August 5, 2014 or is there a way to put a mousedown event only on the left and right side of the screen? Quote Link to comment Share on other sites More sharing options...
enpu Posted August 5, 2014 Share Posted August 5, 2014 Just put mousedown event on your scene, and read the x position:mousedown: function(event) { if (event.global.x < game.system.width / 2) { // Left side } else { // Right side }} doenerklaus 1 Quote Link to comment Share on other sites More sharing options...
doenerklaus Posted August 5, 2014 Author Share Posted August 5, 2014 That worked, thanks 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.