espace Posted September 17, 2018 Share Posted September 17, 2018 hi, i have a sprite and i use another sprite who follow the first. update:function(){ sprite2.x=sprite1.x sprite2.y=sprite1.y }, is there a benefit in this case of using group ? Link to comment Share on other sites More sharing options...
dude78 Posted September 17, 2018 Share Posted September 17, 2018 @espace what way are you gonna use a group in? Link to comment Share on other sites More sharing options...
espace Posted September 17, 2018 Author Share Posted September 17, 2018 If sprite1 is a group and I add sprite2 to this group, I don't need to update the position of sprite2 to follow sprite1. My question : is there a benefit in term of cpu for that? Link to comment Share on other sites More sharing options...
Yehuda Katz Posted September 17, 2018 Share Posted September 17, 2018 Espace, you cannot see the difference if you use a group from CPU point of view. However the difference exist simply because lets say your both sprites are in game.world, if you use wrapper group it means they are inside game.world.warp_group so it means when Phaser will need to calculate where to draw sprites, it should first get local bounds of group and apply them sprite's x/y. Those calculation are so simple that I would prefer use group which makes code simpler and easier to understand. Therefor there is a less chance to make more important, logical mistake in future when games gets bigger ? espace 1 Link to comment Share on other sites More sharing options...
espace Posted September 20, 2018 Author Share Posted September 20, 2018 Thanks Link to comment Share on other sites More sharing options...
Recommended Posts