Setting visible/invisible?

sparkersparker Member Posts: 47
edited November -1 in Working with GS (Mac)
Hi guys,

trying to make an actor only visible when an attribute is of a certain value. Initially it is set to be not visible and that part works well. I have a rule created within the actor which says if the attribute equals what I want it to: (have tried both of these)
self.graphics.visible
and
self.graphics.visible = 1

Also curious, what syntax would I use to make it not visible again (as in via an action of the game, what would I set attribute rule to?

Sam

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    You'll need to use Alpha instead of Visible.
    The Visible Attribute cannot be changed at runtime.

    So set the Actor's Alpha to 0 for invisible, or 1 for visible
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    You can control the visibility by changing an attributes alpha level (its under colour in attributes, 0 = transparent).

    Create a new attribute (an integer) called (graphic.visibiltiy) .. or something like that.

    Then within an actor doesn't have to be the actual one you want made invisible, setup a rule,

    if attribute graphic.visibility = 1 change attribute of your chosen graphic, alpha = 1

    create another rule

    if attribute graphic.visibility = 0 change attribute of chosen graphic, alpha = 0

    Then to make it work with a button for example (a sort of toggle on off button)

    Have another rule, put onto the button, if mouse button down, and mouse position inside. change attribute, graphic.visibility to (graphic.visibility+)%2

    This way each time the button is pressed the graphic.visibility integer value will change from 1 and 0.

    Hope that makes some sort of sense, only learning my way round GS still, but have been using lots of buttons in my first app idea so far.
  • sparkersparker Member Posts: 47
    Brilliant thanks guys - never heard of 'alpha' before so visible seemed like the obvious choice. My bad, game working as expected now :)

    Sam
  • micahmicah Member Posts: 85
    heh, posted in wrong thread
  • TrisTris Member Posts: 58
    As old as it is, this thread just saved me heaps of time. Thanks!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    firemaplegames said:
    The Visible Attribute cannot be changed at runtime.

    If this is still true, 4 months on, I wonder what the point of Visible attribute is?

    Edit: oh, I guess to toggle invisibility temporarily while editing only, I suppose.
    ---------------------------------------------------------------
    Spiral Gyro Games

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • charlieaf92charlieaf92 Member Posts: 84
    Is there any optimization or performance game by switching alpha to 0 like there is with turning off visible?
  • chosenonestudioschosenonestudios Member Posts: 1,714
    No the GE still has to render it and load it into memory wether you can see it or not, unfortunately. :/
Sign In or Register to comment.