Jump to content

InputOver events not firing on the second load of a state


HarryBrook
 Share

Recommended Posts

Hi there,

Can anyone tell me what I'm doing wrong here?

I just need an array of sprites with inputOver events. Right now it works on the first load of the menu and not thereafter. It needs to load 4 times in the game.

Currently I'm doing this:

var createPanels = function(){
    // draw panels
    for (var i = 0; i < 4; i++) {
      
        lightPanels[i] = game.add.sprite(ProgressModel.gameRooms[i].x * game.width, ProgressModel.gameRooms[i].y * game.height, 'room-light-' + (i + 1)); 
        lightPanels[i].name = i;
        lightPanels[i].inputEnabled = true;
        lightPanels[i].events.onInputOver.add(over, this);
        lightPanels[i].events.onInputOut.add(out, this);
        lightPanels[i].events.onInputDown.add(selectRoom, this);
        lightPanels[i].events.onInputUp.add(Up, this);
    }
    
  };

How should you create sprites in an array with events that are reusable on subsequent state loads?

There are no errors, the inputOver event just doesn't fire (the input down works fine every time)

Any input is much appreciated.

Thanks,

H

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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