Way to change actor image when spacebar is pressed?

tannerozzytannerozzy Member Posts: 2
edited November -1 in Working with GS (Mac)
I'm creating an alien conquerers type game and I want to use about a dozen different images as the bullets/lasers. I've played around with it for a little while, but still can't figure it out. Does anyone know how to set it where every time I press spacebar the actor uses a new image?

Thanks for any help!

-Tanner

Comments

  • mangaroomangaroo Member Posts: 419
    global attribute integer = NEWRULE

    when spacebar is pressed +1 to NEWRULE

    when NEWRULE is x or x or x

    change image to

    :)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    create a self attribute in the actor that you are changing the image on (integer attribute).

    Rule when space is down
    change self.attribute to (self.attribute + 1)%5

    NOTE - "5" would allow you to switch between 5 different images so change it to whatever you want.

    Name your image files so they are all the same except a number (i.e. image1.png, image2.png, image3.png, etc.)

    Then inside the same rule above add this:

    change attribute self.image to "image"..self.attribute..".png"
  • tannerozzytannerozzy Member Posts: 2
    Thanks for the responses. I still haven't been able to make it work though. Could you look at the linked image(s) and see what I am doing wrong?

    This is what I have for the rule:
    http://pix.am/EZwh.png

    And this is the full application view:
    http://pix.am/bz8z.png

    I really do appreciate the feedback. It's great being a part of a reliable and supportive community!
  • Rob2Rob2 Member Posts: 2,402
    change self.attribute to (self.attribute + 1)%5 should be a change attribute but you have made it a rule condition
Sign In or Register to comment.