Actors affecting other actors through game attributes

SprucieSprucie Member Posts: 12
edited November -1 in Working with GS (Mac)
I'm having some trouble making one actor trigger the behavior of another. Specifically, I want one actor (a button) to change the visibility of another actor (like a light being turned on). I also want the light's on-ness to cause other things to happen -- like running an animation of the light coming on -- so I don't want to constrain the light's self.graphics.visible exclusively. From poking around on these forums, it sounds like the best way to do that is like so:

---
Game attribute:
game.light_on(boolean)

Button Actor:
Rule: if touch is pressed, set game.light_on to true

Light Actor:
attribute: self.on
Constrain self.on to game.light_on
Rule: if self.on is true
set self.graphics.visible to true
animate
//some other stuff
---

However, despite this seemingly simple situation, pressing the button does *not* do any of the actions I want: no visibility, no animation, no other stuff. Nothing happens (although through testing I have determined that game.light_on is indeed being set correctly).

If I could, I'd like to constrain the animation and visibility and stuff to game.light_on as well -- so it updates continuously -- but my understanding is that I can't constrain attributes of different data types. (In other words, I can't somehow say "watch this game attribute and fire off an animation as soon as the attribute becomes value X.")

What am I missing? Do I have some fundamental misunderstanding? I come from a programming background and sometimes I have difficulty translating my usual way of doing things to the GS model.

Thanks!

Comments

  • SprucieSprucie Member Posts: 12
    Thanks for the reply. If I'm understanding you correctly, you're saying that instead of the light actor having its own "copy" of game.light_on (self.on), I should just have the light actor check game.light_on directly. Is that right? Like this:

    ---
    Game attribute:
    game.light_on(boolean)

    Button Actor:
    Rule: if touch is pressed, set game.light_on to true

    Light Actor:
    Rule: if game.light_on is true
    set self.graphics.visible to true
    animate
    //some other stuff
    ---

    Unfortunately, I tried this and it also didn't work -- with the same results: nothing happened. Despite my rule "if game.light_on is true then do a bunch of things...", none of those things happened.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    the self graphics visible attribute cant be changed in game
  • SprucieSprucie Member Posts: 12
    Weird! I would never have guessed that. Is there a best-practice way to make something disappear and reappear? Change its image to no image? Cover it with another actor that pops on and off screen? Something else?

    Also, is there some way to find out if there are other attributes that can't be changed in game? Those would probably be good for me to know about so I don't beat my head against a wall for two hours. =)

    Thanks!
  • DSlamDSlam Member Posts: 1
    You could use "replicate" which would be invisible if the value is 0 and show a single image if the value is 1.
Sign In or Register to comment.