Jump to content

onInputOver/onInputOut not working on group members.


christian.tucker
 Share

Recommended Posts

I know, I've posted a few questions here in a pretty quick link (Three in two days), and this should be one of my last ones. I just started with Javascript yesterday, but I already have a fairly decent platform, with a combat system in place, etc.

 

I wanted to move my HUD into a group, and have all of my buttons inside of it. The only problem was that as soon as I made the buttons part of the group, they no longer had hover functionality. 

 create: function() {        // Draw UI        hud = game.add.group();        hud.position.setTo(0, 496);        hud.create(0, 0, 'hud-bg');        hpBar = hud.create(270, 17, 'hp-fill');        expBar = hud.create(270, 41, 'exp-fill');        buttonA = hud.create(10, 32, 'phbutton', this.phClick, this, 2, 1, 0);        buttonA.onInputOver.add(this.phHoverIn, this);        buttonA.onInputOut.add(this.phHoverOut, this);    },    update: function() {    },    phClick: function() {    },    phHoverIn: function() {        buttonA.loadTexture('phbuttonhover', 0);    },    phHoverOut: function() {        buttonA.loadTexture('phbutton', 0);    }

If I however, create buttonA using Game.add.sprite instead of group.create()  the hover starts working again. 

 

I don't see anything in the documentation stating this: http://docs.phaser.io/Phaser.Group.html

Link to comment
Share on other sites

Yeah you were trying to pass Button parameters to Group.create, but that only creates Sprites. Sorry I forgot to edit that bit out of my reply, but have done so now!

 

If you want to add Buttons to a group then make them in advance and just use Group.add to add them.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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