How do I change the animation frames of a sprite that is inside a container?

0 favourites
  • 8 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • I created a container of a box and included 3 sprites with 3 frames each, which would be the labels that would appear on the box. I intend to create 3 boxes and each one will show different labels as I determine in the code. Each box will have an ID variable that will be assigned at the time of creation. I need to know how to control the frames of each box individually using this ID.

    I tried this code, but it didn't work:

    + System: Pick BoxP where BoxP.id = 1

    + SymbolsP1: Is overlapping BoxP

    -> SymbolsP1: Set animation frame to 2

  • If they're in a container, just use for each symbolsp1, set animation frame to box.id, where boxpid should be the animation frame you want.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Actually I have symbolsP1, symbolsP2, ... symbolsP4, and each symbol may be displaying a different frame, according to what I want each one to show.

    I will also have several boxes (which is the container spawned) on the screen, that is, each one with a different ID and I need to control each of the frames of the labels that are inside these containers, which will show different frames.

    e.g.

    box.id=1 : label1 = frame 1 / label 2 = frame 3...

    box.id=2: label1 = frame 4 / label 2 = frame 1...

  • Then

    System: For Each SymbolsP1

    If BoxP.id = 1 > Set SymbolsP1 animation frame

    If BoxP.id = 2 > Set SymbolsP1 animation frame

    If BoxP.id = 3 > Set SymbolsP1 animation frame

    ect

    If they are in a container, the associated boxp will be picked automatically, after picking each symbolsp1 individually in for each.

  • EDITED:

    Thank you! It's working now.

  • if I want to rotate the "box" object to any angle, what would I need to do to rotate the other objects inside the container so that they are at the same angle as the box, in this case, on the axis itself?

  • For each box (or object)

    Set object.angle to box.angle

    Or you can do it on created instead of for each.

  • Thank you for your help

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