change attribute or change image....?

Hi iam new to gamesalad...please helpme...
I have signal lights..red green blue..
For each light..i have 2 images...
Redoff.png
Redon.png
Same for other lights
In my scene i have 3 actors for each light
So if i click on red actor...image should
Change redoff.png to redon.png by using change image.
But what i need is ,i want on off.. by shifting..images on and off
I mean iwant to blink that actor...by changing images...till i press on other light

Thanks

Best Answers

  • bjandthekatzbjandthekatz Orlando, FlPosts: 1,375
    edited October 2013 Accepted Answer
    Use the animate behavior.

    Edit, A little more detailed:

    Create an integer attribute. I'll call it Light

    Inside Red light:
    When touch is pressed change attribute game.light to 1
    Rule: when attribute game.light is 1, animate (Red On, Red Off)

    Inside Blue light:
    When touch is pressed change attribute game.light to 2
    Rule: when attribute game.light is 2, animate (Blue On, Blue Off)

    Inside Green light:
    When touch is pressed change attribute game.light to 3
    Rule: when attribute game.light is 3, animate (Green On, Green Off)

    Hope this helps.
  • hiddevandijkhiddevandijk Posts: 17
    edited October 2013 Accepted Answer
    Hi There. Welcome to the forum. The best way to do this is to use a boolean game attribute. If you plan to use triggers to control the lights. Is works like this:


    Imagine you have a scene with roadworks and a traffic lights on both sides. The one on the left side is red and the one on the right is green.

    1. Now create one game boolean attribue and name it LightSwitch.

    2. Create two actors for each of the traffic light names TrafficLightLeft and TrafficLightRight plus two actors named SwitchLeft & SwitchRight that act like a triggers for the lights.

    3. Go into the SwitchLeft actor and create a rule: When "touch" is pressed, change attribute LightSwitch to 'true' (without the ' '.) Make sure to press the e-symbol before entering the formula.

    4. Go into the SwitchRight actor and create a rule: When "touch" is pressed, change attribute LightSwitch to 'false' (again without the ' '.) Make sure to press the e-symbol before entering the formula.

    5. Go into the TrafficLightLeft. Add Timer. Set to After and 0 seconds. Set run to completion to on. Add a rule to this timer: If attribute LightSwitch = true, then Change Image to RedLight, Otherwise Change Image to Green light

    6. Go into the TrafficLightRight. Add Timer. Set to After and 0 seconds. Set run to completion to on. Add a rule to this timer: If attribute LightSwitch = false, then Change Image to RedLight, Otherwise Change Image to Green light.

    That should do the trick. Below a link to the scene file. It will be available for 7 days.

    http://we.tl/mWuOV3uHVw


    Hidde.


  • gyroscopegyroscope I am here.Posts: 6,598
    edited October 2013 Accepted Answer

    Hi @madhanlab So make sure your Play Sound behaviours have Run to Completion unchecked as @FryingBaconStudios says, then add the following:

    First, make an attribute, could be a boolean if there are just these two buttons, or an integer for 2 or more buttons. Make it an integer in this case. Let's call it SoundMode.

    In your first button, add to the When touch is pressed Rule:

    Change Attribute SoundMode to 1

    --then another Rule:

    When SoundMode = 1
    Play Sound Your First Sound

    Then in your second button, add to the When touch is pressed Rule:

    Change Attribute SoundMode to 2

    --then another Rule:

    When SoundMode = 2
    Play Sound Your Second Sound

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

Answers

Sign In or Register to comment.