Timed Shoot and NoShoot button

nizzar27nizzar27 Member Posts: 8
edited February 2014 in Working with GS (Mac)
Hi

I have a button that has two images 1 is for shooting 2 is for not shooting (limiting players rate of fire)
It should work like this - When i press actor then it should shoot once and change image to noshoot. when image noshoot is up you cant shoot. after timer elapses change back image to shoot, so u can shoot again..... and so on

CODE IN Shoot button

RULE
If touch is pressed & Self.Image is Shoot
DO
spawn shoot actor
change image to NoShoot
END

RULE
Self.Image is NoShoot
DO
Timer->change image to Shoot
END

Result of this is I keep pressing the button and nothing happens :(

Please help
plsssss

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I've always done this with booleans or integers but I don't see why it wouldn't work for images. Make sure that the names of your images are EXACTLY Shoot.png and NoShoot.png. In fact, as a test you should place another actor on the scene and do Change Attribute self.Image to Shoot.png. Does the actor show up with the correct image? Do the same for Change Attribute self.Image to NoShoot.png. Does that work also?

    What is the exact Timer set up you have? Have you tried checking Run to Completion?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • nizzar27nizzar27 Member Posts: 8
    I was really specific about the image names and its not working like that.

    So I have created a variable canshoot - boolean
    and replaced the if image to if canshoot

    now its working but idk why wasnt the image thing working

    thx :)>-
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I'm not sure why the images weren't working. If you want to send me a link to download your project file, I can let you know the reason. Otherwise, I'm glad to hear it's working with a boolean.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.