Phempt Posted November 19, 2014 Share Posted November 19, 2014 Hi guys, I'm coding a game that by clicking on the whole screen start the jump function for the character. I used this code:mousedown: function(){ if(player.onGround == true){ player.velocity.y = -player.velocityLimit.y; player.mass = 1; player.onGround = false; } }it works, the character jumps. but If I've a button, for example: this.logo = new game.Sprite('[email protected]'); this.logo.interactive = true; this.logo.position.x = game.system.width / 2; this.logo.position.y = game.system.height / 2; this.logo.anchor.set(0.5,0.5); this.logo.scale.set(0.9,0.9); this.logo.addTo(game.scene.bgContainer); this.logo.click = this.logo.tap = function(){ console.log('test'); }I see the "test" log into the console, but my character jump due to "mousedown" function. is there a way through the framework to block the mousedown interaction while a button is tapped ? Thank you EDIT: I tried to add to mousedown function a "interactive" control but: mousedown: function(object){ if(object.interactive != true){ if(player.onGround == true){ player.velocity.y = -player.velocityLimit.y; player.mass = 1; player.onGround = false; } } }without success... Sir_Everard 1 Quote Link to comment Share on other sites More sharing options...
Sir_Everard Posted November 19, 2014 Share Posted November 19, 2014 What is your object target when you click/tap on the button? It might be a click container issue and you will have to write your own hittest for it. Quote Link to comment Share on other sites More sharing options...
Phempt Posted November 19, 2014 Author Share Posted November 19, 2014 I think I can create 2 container 1 for jump 1 for pause button (resume button, restart..)I want to understand if there's a better way to do this Sir_Everard 1 Quote Link to comment Share on other sites More sharing options...
enpu Posted November 20, 2014 Share Posted November 20, 2014 Instead of using scene's mousedown function, create new container for your mouse events:var touchLayer = new game.Container();touchLayer.interactive = true;touchLayer.hitArea = new game.HitRectangle(0, 0, game.system.width, game.system.height);touchLayer.mousedown = function() {};touchLayer.addTo(this.stage); Phempt 1 Quote Link to comment Share on other sites More sharing options...
Phempt Posted November 20, 2014 Author Share Posted November 20, 2014 thank you enpu! You rock! 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.