Changing an instance variable by

0 favourites
  • 10 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • What I want to do is change an instance variable of one instance of an object when I click on a second or different instance of that object.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Maybe I should clarify what I want to do a bit more.

    I click on sprite 1 - it "lights up"

    I click on a different instance of sprite 1 - it "turns off" the original sprite.

  • If you have a boolean for each sprite, then have a event like:

    • the booolean im refering to is: IsOn for this example

    Mouse.OnObjectClicked(Sprite1)

    Sprite1.isIsOn

         -> Do what you want here for Sprite1

    Mouse.OnObjectClicked(Sprite2)

    Sprite2.isIsOn

         -> Do what you want here for Sprite2

  • What I have is about 100 blocks. I click on a block and it changes that block by changing the opacity, and it turns on its instance variable and a global variable. If I click on a different block, I want to make the original block go back to its original state.

    All the blocks can go to their start-up state as well, if that helps...

  • Don't know if this fits the bill perfect but it's the first idea that came to mind from your original post.

    in short.

    on click sprite.

    Turn off all sprites

    Turn on the one clicked.

    example .capx

  • Thanks, that seems to do exactly what I want. Seeing the cap helped (sub event).

  • Another way would be to make a global variable "TurnedOn".

    Startup

    -> Set "TurnedOn" to Sprite.UID //You can use an instance ID to select which one...

    Mouse.On click Sprite

    ->Set "TurnedOn" to Sprite.UID

    Every Tick

    ->Sprite Pick UID="TurnedOn"

    -->Sprite Play LightUp animation

    Then set up so any other time it plays the default animation

  • Another way would be to make a global variable "TurnedOn".

    Startup

    -> Set "TurnedOn" to Sprite.UID //You can use an instance ID to select which one...

    Mouse.On click Sprite

    ->Set "TurnedOn" to Sprite.UID

    Every Tick

    ->Sprite Pick UID="TurnedOn"

    -->Sprite Play LightUp animation

    Then set up so any other time it plays the default animation

    Thanks, that looks good too, glad to learn more about using the Sprite.UID

  • gazoogle: you might profit frome checking out the "Picking/selecting instance(s)" section in the how do I FAQ.

    There are a few examples (the "Understand how to use instance variables to pick specific objects " topic is really a nice read imo).

  • Ah yes, I will read through those. I should have looked in that post. Thanks!

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