Paired instance variable example in the manual

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • i have 4 instances of a rectangle sprite and 4 instances of a text

    on mouse left clicked on sprite --> Sprite Add to ClickCount 1

    text n should display sprite(n).ClickCount

    so System.Every tick --> Text.Set text Sprite.ClickCount everything works as expected

    It seemed to me that since the mouse click was selecting the nth Sprite, that it would be more efficient to move the Text.Set action under the on mouse condition with the expectation that only the nth Text would be set.

    however, it sets every Text???

    Then I added, if ClickCount>=3, the Sprite Opacity is decremented as intended

    Added an Opacity==0 Condition for Sprite to Destroy it, and added a 2nd action to destroy the Text.

    However, it destroys every Text.

    If I have paired instance such as 4 sprites and 4 texts, how can I manipulate only a pair at a time?

    [/url=https://drive.google.com/open?id=0B-YDf0p_IiqvbzNwa2pjQ3VWU1E]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah you're not 'picking' the text correctly so it's assigning it to all. You can resolve this easily by putting the sprite and text object in a 'container'. Whenever the sprite is created, it creates the text box with it, and the events should link the sprite to its own text object.

  • thanks much.

    i was wondering about containers but hadn't gotten that far yet.

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