pranadevil Posted March 14, 2016 Share Posted March 14, 2016 is there a way to create an array like: x = [ w,e,r,t]; in phaser? Link to comment Share on other sites More sharing options...
icp Posted March 14, 2016 Share Posted March 14, 2016 Yes: var mySprites = [sprite1, sprite2, sprite3, sprite4]; However I would use groups because they have some methods that may come handy: this.spriteGroup = this.game.add.group(); this.spriteGroup.add(sprite1); this.spriteGroup.add(sprite2); this.spriteGroup.add(sprite3); this.spriteGroup.add(sprite4); You can also use both arrays and groups. Link to comment Share on other sites More sharing options...
pranadevil Posted March 14, 2016 Author Share Posted March 14, 2016 2 hours ago, icp said: Yes: var mySprites = [sprite1, sprite2, sprite3, sprite4]; However I would use groups because they have some methods that may come handy: this.spriteGroup = this.game.add.group(); this.spriteGroup.add(sprite1); this.spriteGroup.add(sprite2); this.spriteGroup.add(sprite3); this.spriteGroup.add(sprite4); You can also use both arrays and groups. thanks for the answer, finally could you please gimme and example of how can i figure it out "where" is an specific item in the group ? for example is there a way to know that in index 2 is sprite3? and then erase it from the group? Link to comment Share on other sites More sharing options...
icp Posted March 14, 2016 Share Posted March 14, 2016 Check forEach and remove methods: http://phaser.io/docs/2.4.6/Phaser.Group.html#methods pranadevil 1 Link to comment Share on other sites More sharing options...
pranadevil Posted March 15, 2016 Author Share Posted March 15, 2016 thanks man! Link to comment Share on other sites More sharing options...
Recommended Posts