attributes

Hi, i would like a little bit of help please. Ive been debating about posting until i can try and get my had round it. Ive found a work around for my issue but im not happy with it really, sound a bit newbie, but it works. However, id love it, if i can somehow figure out the real issue.

When using the attributes. Im just going to explain its going to be easier.

I have an actor that acts as a button.
i have a game integer set to 0
and in actor that acts as an image changer.

in the actor that is the image changer

//rule//
if GAME.CHANGER = 1
CHANGE IMAGE TO A
END RULE
//rule//
if GAME.CHANGER = 2
CHANGE IMAGE TO B
END RULE
//rule//
if GAME.CHANGER = 3
CHANGE IMAGE TO C
END RULE

clicking on my button>
IF attribute GAME.CHANGER = 0
ON TOUCH
SET ATTRIBUTE TO 1
END RULE//

//RULE2//
IF attribute GAME.CHANGER = 1
ON TOUCH
SET ATTRIBUTE TO 2
END RULE//

//RULE3//
IF attribute GAME.CHANGER = 2
ON TOUCH
SET ATTRIBUTE TO 3
END RULE//

But, it doesnt work.. however, when i change the touch commands to PRESS and next ruule for DEPRESS ect it works.
It would appear i cant keep clicking TOUCH to keep changing images??

Comments

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276
    edited April 2016

    You need only one rule for the touch command

    When touch is pressed

    Do:
    Change attribute game.changer to mod(game.changer,3)+1

    That will cycle the attribute from 1 to 3, and back to 1.

    That should fix your problem.

    Mental Donkey Games
    Website - Facebook - Twitter

  • sonicm3sonicm3 Member Posts: 141

    thankyou very much indeed, works perfect, thanks so much

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    You see what happens there right? When you push the button the first rule fires changing the number which triggers the second rule and so on and so on. This is called logic. Code fires in .03 of a second and a touch lasts longer than that.

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2016

    @MentalDonkeyGames said:
    You need only one rule for the touch command

    When touch is pressed

    Do:
    Change attribute game.changer to mod(game.changer,3)+1

    That will cycle the attribute from 1 to 3, and back to 1.

    That should fix your problem.

    @sonicm3 said:
    thankyou very much indeed, works perfect, thanks so much

    You can simplify this even more.
    Dump all the rule and attributes and name your images 0, 1 and 2.
    Then you need just one rule:

    When touch is pressed
    --Change self.image to mod(self-image+1,3)

Sign In or Register to comment.