How do I? Make an instance change frame based on another instance of the same sprite?

0 favourites
  • 7 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • So I have a sprite that is part of a instance group of itself. 4 instances per group.


    1 2

    3 4

    5 6

    7 8

    I have a group_id variable for each set. and 1 and 5 have a Var1 = -1 all the others have -2

    I made all instances with a var-1 set to a random number that corresponds to a animation frame.

    I want to instances 2,3,4 to copy the random 1 frame

    6,7,8 copy 5

    Trying to make the var=-2 just copy the random value var=-1 creates

    Can make it work easy using two different sprites but is their a way to do it with one sprite? Some operations with the 2 sprite method are not working. Example: mirror and flip - when copying the animation frame VS making another sprite with all the same frame and doubling the project size. It would make my project development much smoother to use just the one sprite that could be used with behaviors or modified in additional ways with more variables in one sprite.

  • This is one of the most popular questions here - how do you refer to two different instances of the same object in one event.

    In expression editor you can use instance IID. For example:

    Pick instance of sprite -> Sprite set animation frame to Sprite(7).AnimationFrame

    Where 7 is the IID of the second sprite instance.


    Alternative method is to use a family. Add your sprite to a family, and then you can pick one instance of the sprite, and one instance of the family in the same event.

    Pick instance of sprite
    Pick instance of family
     -> Sprite set animation frame to Family.AnimationFrame
  • "This is one of the most popular questions here"

    Yeah I have have had problems with it a few times :)

    Figured some of it out. Thanks Dop2000. I Think using IID is not the best practice. Ended up passing some variables through another holder sprite. And it works however I am getting a weird result with mirroring the color sprite I was using underneath the "charm" Seems like even when mirrored it wants to display in the other direction as well and You get this weird image ripping effect.

    See the attached picture:

    Also what would be a more elegant way of doing this:

  • Also what would be a more elegant way of doing this:

    CHARM_COLOR set animation frame to CHARM_COLOR.Charm1

  • Thanks dop2000

    So this should probably be a new thread but I tried moving the top right charm_multiuply and its loading the right image however if you look at the bottom right bird its as soon as the multiply covers the correct image it flips the displayed image back. Is this an error in construct. Has anyone else experienced this?

    Updated CAPS

  • Your project is quite big and messy, it's hard to find the problem, I can't even reproduce it. Make a small test project and maybe we could help.

    If you are using charm_multiply sprite just for the multiply effect, you can make it square shape. It doesn't need to be the same shape as the original sprite, as soon as they are both on a separate layer and you set "Force own texture=Yes" on the layer.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • OK I'll try that. I'll see if I can fix it in a simple version. I stripped down the 36 other layouts in the on the project to post this problem but their are lots of "leftovers" - sorry about that. Thanks for taking a look.

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