Choeeey Posted February 2, 2015 Share Posted February 2, 2015 Hi there, Basically I have a group: this.walls = game.add.group(); And I add a LOT of walls, but each time I do I need to scale them like so: this.wall1 = this.add.sprite(positionx,positiony, 'wall', 0, this.walls); this.wall2 = this.add.sprite(x,y, 'wall', 0, this.walls); this.wall3 = this.add.sprite(x,y, 'wall', 0, this.walls); this.wall4 = this.add.sprite(x,y, 'wall', 0, this.walls); this.wall1.width = this.wall1.width*scale; this.wall1.height = this.wall1.height*scale; this.wall2.width = this.wall2.width*scale; this.wall2.height = this.wall2.height*scale; this.wall3.width = this.wall3.width*scale; this.wall3.height = this.wall3.height*scale; this.wall4.width = this.wall4.width*scale; this.wall4.height = this.wall4.height*scale; Is there a way I can scale the whole group in one? Link to comment Share on other sites More sharing options...
redsheep Posted February 2, 2015 Share Posted February 2, 2015 this.walls.scale.set(scale,scale);check this example http://examples.phaser.io/_site/view_full.html?d=groups&f=group+scale.js&t=group%20scale Link to comment Share on other sites More sharing options...
Choeeey Posted February 2, 2015 Author Share Posted February 2, 2015 this.walls.scale.set(scale,scale);check this example http://examples.phaser.io/_site/view_full.html?d=groups&f=group+scale.js&t=group%20scaleIt is the width and height I want to scale though? not the x and y axis Link to comment Share on other sites More sharing options...
Raicuparta Posted February 3, 2015 Share Posted February 3, 2015 You're saying you want to scale each element but not the distances between them? You'll have to resize each one individually, but you can do this with forEachAlive:create: function(){ this.walls = game.add.group(); //(...) //add walls to group... //(...) this.walls.forEachAlive(this.resizeWall, this);},resizeWall: function(member) { member.scale.set(scale)}This will cycle through all the elements of the group and resize them individually. Just remember that they're resized around the anchor point, so you might want to change that. Choeeey 1 Link to comment Share on other sites More sharing options...
Recommended Posts