Jump to content

Input on rect


i3Designer
 Share

Recommended Posts

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);

 

post-7059-0-76699800-1401807856.png

post-7059-0-04667500-1401808086.png

Link to comment
Share on other sites

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 :D 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

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
 
 

 

post-7059-0-53412200-1401829070.png

post-7059-0-35892200-1401829144.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...