Jump to content

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


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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