Jump to content

Phaser CE: sprite onClick, switching sprite between groups loses the sprite.


ogrotten
 Share

Recommended Posts

I'm building a card game. 6 columns (phaser groups) of 5 cards. The goal is to click the card on top and move it to the discard group. 

Currently, when i click the card, it is apparently removed from rendering. Console shows visible = true, it's new parent group shows visible = true, coords are valid, and the console shows that the new group has it and the old group has removed it. I can move the clicked card on xy, no problem. But as soon as I try to add it to a group, it disappears.

Here's the entire source on JS Fiddle. The callback function for the interaction is function tap() and lives at the bottom, of the source.

 

Link to comment
Share on other sites

Based on the spriteinfo, the 'bounds' info is different whenever I click another card. When I click the faceup card on the 2nd stack, bounds changes to x:141.5 y:160 with W and H remaining unchanged.

Is it possible that the rectangle that frames the card is moving around without the underlying spritesheet, or something like that?

Link to comment
Share on other sites

I figured out the problem.

The destination group pivot point was set to px 400,500. Then the incoming sprite had was also placed at 400,500. that means that the card was put at worldcoords of 800,1000. once I figured that out, the sprite appears where it needs to.

Thanks for the replies.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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