Jump to content

set a group sprite in order, then each the item in the group


sinanqd10
 Share

Recommended Posts

Hi everyone,

I want to create a group of sprite image which contains something:

eg: in the sprite image I have number 1 , 2 , and 3

then I have a button that set the sprite frame which generates in order without removing the previous frame.

eg: set the sprite frame into game world 1, 2, 3, 3, 2, 1, 3, 1, 2. something like that.

Therefore, I want to get all the frames that I have set in the group in total number.

Can anyone kindly share me some useful way to do it?

 

this is my sample coding:

var group;var f;var btn;gameState = {preload: function() {     game.load.spritesheet('sprite123', 'assets/123.png', 10, 8);     game.load.spritesheet('button','assets/button.png)',80,10);},create: function() {     group = game.add.group();     f= group.create(0,0,'sprite123');     btn = game.add.button(200,300,'button',this.button,this,0,1);},button: function() {     f.frame = game.rnd.between(0, 2);}}

This is just my idea, please anyone shares me the best way to achieve my objective.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...