problem with controls

pjnolenpjnolen Member Posts: 152
edited November -1 in Working with GS (Mac)
Looking at TK's Platformer Template, because mine kept freeking out and not working properly, I'm trying to emulate what he did in my game.

But, it's not working properly. I've gone so far as to recreate each behavior and attribute exactly, but i'm still having a problem.

TK's left and right buttons work perfectly fine, but if I make them in my game, and go down the list of rules and put them in exactly how he has them, when you press the left/right buttons, the actor moves left and right, AND it changes the graphic in his. If I do this exactly the same in my game, when you press the button and set the move left attribute to 'true' it STAYS 'true' and the actor just runs off the screen and the graphic doesn't revert back to the original.

I can't find a single instance where TK's rules change the attribute BACK to false, nor one that changes the graphic BACK to the original but it's doing it fine in his build, even though i have the exact same commands, it's not reverting back to 'false' when i take my finger off the button.

the following rule is for the button to run right-

(actor recieves event "touch" is "inside")
(change attribute "game.goingRight" to "true")

Which is simple enough.

And the following rule for the movement of the character actor -

(attribute "game.moveright" is "true")
(attribute "game.moveleft" is "false")
(set image to "hero_right.png")
(constrain attribute "self.motion.linear velocity.X" to 300)

Which is fine as well. BUT I can't find any command in his rules to reset the attribute "game.moveright" BACK to false.

If it stays as true the actor just keeps moving to the right at 300 and it keeps the hero_right.png graphic.

Even though I have went through line for line and setup the rules the same way, if i take my finger off the 'run right' button the actor just KEEPS running right and the graphic STAYS as run right permanently.

Yet his doesn't.

Can someone explain to me what I'm missing? The only thing I can assume is that the following rule-

(actor recieves event "touch" is "inside")
(change attribute "game.goingRight" to "true")

when you take your finger off, resets the attribute back to false.

He also has a rule that-
(attribute "game.goingright" is "false")
(attribute "game.goingleft" is "false")
(set image to "hero_right.png")
(constrain attribute "self.motion.linear velocity.x to "0"

THIS rule tells me that if they are both false, to reset the actor to 0 speed and original graphic, but what I don't understand is that I don't see any rules MAKING that attribute false anywhere.

Yet when I release my finger from his button, his actor stops, and if I do the same on my button in my game, it just keeps going.

What am I missing?

Comments

  • DrGlickertDrGlickert Member Posts: 1,135
    Ahh, looks like a simple fix. In the OTHERWISE, set the attribute to true/false (which ever is opposite of what the rule sets it at).

    Check out this video by TShirtBooth for another explaination;

    http://www.youtube.com/user/GameSaladCookbook#p/u/34/RKiJE1pa4Dc

    With the OTHERWISE utilized in the rules when the player takes their finger off the button the actor will stop moving. The TSB video really helps understand the OTHERWISE portion of the rules.
Sign In or Register to comment.