How do I set copies of sprites with each different frame

0 favourites
  • 3 posts
From the Asset Store
three fully animated characters ideal for your RPG side scroller projects
  • 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? <img src="{SMILIES_PATH}/icon_e_confused.gif" alt=":?" title="Confused">

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Oh my, that worked perfectly, the alternative version you suggested. That was a simple solution, thank you so much.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)