sinanqd10 Posted November 19, 2014 Share Posted November 19, 2014 I want to generate a group which display dynamically in order and give a little bit margin right.eg: In the game world, It will generate 1 little space 2 little space 3 little space 4 etc...What method should I use?Can anyone please guide me?Thanks in advance. Link to comment Share on other sites More sharing options...
sebamawa Posted November 19, 2014 Share Posted November 19, 2014 To clarifying ideas: sprite1, space, sprite2, 2*space, sprite3, 3*space, ... Correct: sprite1, space, sprite2, space, sprite3, space, ... So something is what you want? Link to comment Share on other sites More sharing options...
sinanqd10 Posted November 19, 2014 Author Share Posted November 19, 2014 @sebamawaYes this is what I wanted, but it will render dynamic positioning.Can you share me some examples? Link to comment Share on other sites More sharing options...
sebamawa Posted November 19, 2014 Share Posted November 19, 2014 What kind of object is your group? (game object) Once rendered, all behave the same? I think what you want can be done by programming, but I need more info, or some code. Regards Link to comment Share on other sites More sharing options...
sinanqd10 Posted November 19, 2014 Author Share Posted November 19, 2014 Here it is:var groupWinLoseDraw;var f;var myGame = { preload: function() { this.game.load.spritesheet('sprite123','assets/sprite123.png',30,10); this.game.load.spritesheet('button','assets/button.png',40,20); }, create: function() { groupWinLoseDraw = game.add.group(); f = groupWinLoseDraw.create(200, 30,'sprite123'); var btn = game.add.button(300,400,'button',this.button,this,0,1); }, button: function() { f.frame = game.rnd.between(0, 2); }}This code will output the sprite,but what I wanted to dynamic increase the x position like I mentioned above; eg: 1 space 2 space 3 etc... Link to comment Share on other sites More sharing options...
sebamawa Posted November 19, 2014 Share Posted November 19, 2014 The remaining children of the group? you create just one (f). Or whatever you want to render all frames of spritesheet (sprite123.png) with spaces, like you mentioned above? Link to comment Share on other sites More sharing options...
rvizcaino Posted November 19, 2014 Share Posted November 19, 2014 If your sprites are numbered in sequence (starting at sprite0), try this in your create function...create: function() { var totalSprites = 10; var groupWinLoseDraw = game.add.group(); var space = 50; var spriteWidth = 200; for(var i=0; i<totalSprites; i++){ var positionX = (i*spriteWidth) + (i*space); groupWinLoseDraw.create(positionX, 30,'sprite'+i); }}, sebamawa 1 Link to comment Share on other sites More sharing options...
Recommended Posts