i3Designer Posted June 3, 2014 Share Posted June 3, 2014 I created a var ast = square I can not do that when pressed calls a function.If i use sprite, I can, but with rect, no. ast= new Phaser.Rectangle(0,0,w/2,h/3); ast.inputEnabled=true; ast.enableBody = false; ast.events.onInputDown.add(prova); Link to comment Share on other sites More sharing options...
rich Posted June 3, 2014 Share Posted June 3, 2014 A Rectangle is just a piece of geometry. You can't enable it for Input, or give it a physics body, etc. It's just a rectangle. Link to comment Share on other sites More sharing options...
Mike Posted June 3, 2014 Share Posted June 3, 2014 I've made a example fiddle of how to make a rectangle with input and body enabled... http://jsfiddle.net/BdjV2/ - check the console for console.log. But at the same time i have a second not working as supposed example the real hit/input area is small 32 x 32 (maybe default) size ? So if anybody can explain the mistake in the second approach. I think it will be useful. Link to comment Share on other sites More sharing options...
i3Designer Posted June 3, 2014 Author Share Posted June 3, 2014 I want to create a square that has the width = window.innerWidth / 2 I've tried using the rect but the input is not possible to do so. Then I made a sprite 32 x 32, a blue square, I want the width is windows.innerWidth / 2 var w = window.innerWidth; var h = window.innerHeight; char=game.add.sprite(0,0,'char'); char.inputEnabled=true; char.visible=true; char.scale.x=w/2; char.events.onInputDown.add(alert); i can't do Link to comment Share on other sites More sharing options...
rich Posted June 4, 2014 Share Posted June 4, 2014 char = game.add.sprite(0, 0, 'char'); char.width = Math.floor(window.innerWidth / 2); Link to comment Share on other sites More sharing options...
i3Designer Posted June 5, 2014 Author Share Posted June 5, 2014 Thanks you Rich.I love you Now I can continue working on my game Link to comment Share on other sites More sharing options...
Recommended Posts