How do I set copies of sprites with each different frame

Get help using Construct 2

Post » Tue Aug 23, 2016 3:00 am

So I've been kinda struggling with this, but what I am trying to do is to make a grid with skins for the player to choose. I could always copy and create a new sprite for each frame I got (and I have over 80+), so to copy each is troublesome and wastes memory too since every cloned object is a new object.

http://pasteboard.co/bWpQmwy3t.jpg
http://pasteboard.co/1c2D5tnki.jpg

I know I have to use "for each" and loops and arrays (I am already using an array to determine if the player has unlocked certain skins). I don't know how to set each individual copied sprite to use a different skin (frame) from the previous or next one. Do I use UID's for that and /or IID? :?
B
14
S
3
Posts: 20
Reputation: 840

Post » Tue Aug 23, 2016 3:11 am

You want to use loops to dynamically create and place your grid of sprites, and at the same time you will use the loopindex both for placement and for setting the correct animation frame.

For example, for 80 sprites, and you want to create a grid of 8x10

For "x" from 1 to 8
(subevent) For "y" from 1 to 10

Create sprite at loopindex("x")*sprite.width, loopindex("y")*sprite.height
Set sprite animation frame to 10*(loopindex("x")-1)+loopindex("y")

EDIT: Alternatively, if you have only as many of your sprite on your layout as you have images, you can do a for each sprite, set sprite animation frame to sprite.iid. This may not work correctly if you don't have the same number of sprites as animation frames.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Tue Aug 23, 2016 4:50 pm

Oh my, that worked perfectly, the alternative version you suggested. That was a simple solution, thank you so much. :D
B
14
S
3
Posts: 20
Reputation: 840


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests