willis Posted December 23, 2018 Share Posted December 23, 2018 Hi I'm new phaser user i got a little bug for my game, this things make me confused for an hour. I make mahjong game using phaser 3, the gameplay it's self are already completed, just add additional features. I make hint function to detect possible matches, and it's working fine also selected pieces that are match are right, but if i want to clear selected pieces (hint object), sometimes it's pick the wrong pieces, i already put selected hint id (array) on console.log, and nothing wrong. If i pick gameobject by id (custom properties) dirrectly, sometimes it's pick a different gameobject id. var child = this.cards.getChildren(); for(var i=0; i<2; i++){ child[hinted_pieces[i]].clearTint(); } If i use loop to pick hinted object, it's select the right gameobject. var count = 0; for(var i=0; i<total; i++){ if(child[i].id == hinted_pieces[count]){ child[i].clearTint(); count++; } if(count == 2){ break; } } So, it's Phaser 3 bugs? Link to comment Share on other sites More sharing options...
Milton Posted December 23, 2018 Share Posted December 23, 2018 You should probably ask in the new forum, but anyway: Your hinted_pieces[ i ] probably doesn't work as an index for the child array (only 0 and 1 would work). willis 1 Link to comment Share on other sites More sharing options...
rich Posted December 23, 2018 Share Posted December 23, 2018 The two bits of code do completely different things. Hinted pieces array clearly doesn’t hold the array indexes, but rather the id values. Game Objects in Phaser don’t have an id property, so this is something you added. willis 1 Link to comment Share on other sites More sharing options...
Recommended Posts