• Content Count

  • Joined

  • Last visited

  1. You wouldn't want to declare a function for each card. That's why you include parameter. Instead of card1Effects up to let's say card53Effects, just use cardEffects(index). Index would refer to an integer. Unfortunately, you cannot specify parameters on onInputDown.add so you enclose your function on another one. function create() { //creating array cardarray = shuffle(cardarray); for(var i = 0; i < cardarray.length; i++) { var card = cardarray[i]; card = game.add.sprite(80, 60, 'card' + i); card = inputEnabled = true; card.events.onInputDown.add( function() { cardEffects(i); }, this); } } function cardEffects(index) { // code }
  2. Noticed Creature class doesn't extend Physics Body component. Any idea how to use creature objects on gameplay? I'm thinking of using Groups or parenting it to any object with body, just want to know if there are recommended ways to do it.
  3. use higher-order function insert a parameter on your function function cardEffects(index) {...} call it like this: cardarray[index].events.onInputDown.add( function() { cardEffects(index); }, this); EDIT: I removed index from function() {...}
  4. Thanks. I created a custom build and made sure to include creature module.
  5. I can't seem to follow the example code for Creature animations. I'm getting this error: c.Creature is not a constructor Are there any other things I need to setup?
  6. Checked already. wheelB is not null and the position is 0,0.
  7. I'm having problems transferring sprite from another sprite to stage and then back to another sprite. The scenario is I have two rotating sprites (wheels) and another sprite (player). Initially, the player is added to wheelA as a child. Upon pressing fire, the player is removed from wheelA and its velocity is changed so that it moves away from wheelA. (Player is removed from wheelA so that it ignores wheelA's rotation). The player is also added to the game via game.add.existing(player); (Since it doesn't render after removing from wheelA). On update, I check if player overlaps with wheelB. On overlap, I disable the physics of the player and add it as child of wheelB. The result is player is not rendered on the scene although it is a child of wheelB.