Gorpomon Posted June 17, 2016 Share Posted June 17, 2016 Hello all, I'm trying to re-use sprites like so: squareTargets = game.add.group(); squareTargets.enableBody = true; squareTargets.physicsBodyType = Phaser.Physics.ARCADE; squareTargets.createMultiple(maxSquareTargets, 'square target sheet'); squareTargets.setAll('checkWorldBounds', true); squareTargets.setAll('outOfBoundsKill', true); squareTargets.setAll('hasOverlapped', false); //my own property I use in my logic squareTargets.setAll('frame', 1); // so it displays on the 1 index of my sprite sheet squareTargets.callAll('animations.add', 'animations', 'explode', [1, 2, 3, 0], 5, false); I also want the individual sprite to kill() when the explode animation is run, how do I set this at the group level? I see that I can individually set animations on a sprite and do this: var explode = singleTarget.animations.add('explode', [1, 2, 3, 0], 5,); explode.killOnComplete = true; But I'd rather find a way set the animation on the group and killOnComplete for the animation in one go, rather than loop through the group and define the animation and property (which I suspect is wasteful from a memory point of view). Link to comment Share on other sites More sharing options...
Gorpomon Posted June 17, 2016 Author Share Posted June 17, 2016 I think I see what was wrong, I wasn't passing in the killOnComplete boolean to my .callAll call, like so: squareTargets.callAll('animations.add', 'animations', 'explode', [1, 2, 3, 0], 5, false, true); but I would still appreciate any elaboration on what you can use .callAll to do! Link to comment Share on other sites More sharing options...
rich Posted June 18, 2016 Share Posted June 18, 2016 You use callAll to call a function on every member of a Group, that's it really. setAll sets a property, callAll invokes a function. Groups are just containers, they can't have animations themselves, as they don't have any visual properties (they don't actually render themselves). Only Sprites can. Which is why only Sprites have animation signals (like killOnComplete) Tilde 1 Link to comment Share on other sites More sharing options...
Recommended Posts