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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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