Jump to content

Touch Input On Sprite


Recommended Posts

Weird problem. (Late edit : I see there is a new release that fixes some button issues - perhaps that will fix this)


I had touch input on sprites working perfectly on my home brew button class and now it seems to have broken.


Pointer input ie: mouse still works fine.



When I use the debug class in the update loop

    this.game.debug.pointer( this.game.input.pointer1);    this.game.debug.pointer( this.game.input.pointer2);

I can see the pointer motion - so I know that is working.  It just seems to be that the sprite event handler is not being called.




Has something changed?  I have updated to the most recent code in the last few days.



I am using

evil.Button=function(game, x, y,key,disabled_frame,enabled_frame,flash_frame,cb,cb_ctx){            Phaser.Sprite.call(this,game, x, y);    this.name='basic-button';        this.states={};        this.current_state=null;    this.inputEnabled=true;        this.input.useHandCursor=true;    this.input.consumePointerEvent=true;        this.events.onInputDown.add(this.onDownListener,this);    this.events.onInputUp.add(this.onUpListener,this);        this.flash_time=100;                this.addState('disabled',key,disabled_frame,false);    this.addState('enabled',key,enabled_frame);    this.addState('flash',key,flash_frame,false,cb,cb_ctx);};



evil.Button.prototype.onUpListener=function(){    };evil.Button.prototype.onDownListener=function(){    //basic button is simply a bounce button - doorbell,    //over ride for other behavior        if(!this.current_state.active) return;        if(this.current_state.name==='enabled'){        this.setState('flash');        this.game.time.events.add(this.flash_time, function(){            if(this.current_state.cb!==null){                this.current_state.cb.call(this.current_state.cb_ctx);            }            if(this.current_state.name==='flash'){                this.setState('enabled');            }        }, this);            }};
Link to comment
Share on other sites


  • Recently Browsing   0 members

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