can someone check this coding and telling me what did I do wrong?
![jobei](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Im trying to make a countdown down from 4, what trigger the number to
go down is by hitting other actors on the screen. You hit one actor the
number goes down, hit another actor the number goes down, you get the
idea.
This is the code i have for it , but it not working, the number dont go down
then i hit on and actor. (I put this same code into (prototype) and (Instance)
This is the number actor:
Rule: when all of the following are happening
if game.hitbox1 is true
if game.hitbox2 is true
if game.hitbox 3 is true
if game.hitbox 4 is true
change attribute: set: self.number
to: self.number -4
Then under the rule box, I have.
Display Text:
Display: self.number
(I didnt't check the wrap text inside actor)
Also on the side in the Attributes I made a self integer
called "number" and I put a 4 in the box in front of it.
I have all the hitbox actors set to "touch"
go down is by hitting other actors on the screen. You hit one actor the
number goes down, hit another actor the number goes down, you get the
idea.
This is the code i have for it , but it not working, the number dont go down
then i hit on and actor. (I put this same code into (prototype) and (Instance)
This is the number actor:
Rule: when all of the following are happening
if game.hitbox1 is true
if game.hitbox2 is true
if game.hitbox 3 is true
if game.hitbox 4 is true
change attribute: set: self.number
to: self.number -4
Then under the rule box, I have.
Display Text:
Display: self.number
(I didnt't check the wrap text inside actor)
Also on the side in the Attributes I made a self integer
called "number" and I put a 4 in the box in front of it.
I have all the hitbox actors set to "touch"
Best Answers
-
jn2002dk Posts: 102
I'm a bit confused as to why you want all hitbox to be true at once and why you're subtracting 4 instead of 1 but assuming that's how it's supposed to be then from what you wrote you're using self.number but since it's an integer you're using in 5 actors it should be a game attribute
so change attribute game.numer=game.number-4
and display game.number -
MobileRocketGames Posts: 128
It would be more efficient to have 1 game integer attribute (call it Count and set it to 4) and on each of the boxes have a Boolean attribute and a Rule:self.Boolean is true and receives touch:
So whenever you hit a box, it reduces the count attribute from 4 to 3 and 3 to 2 and so on.
---change attribute game.Count = game.Count-1
---change attribute self.Boolean = false
Then on another actor in the scene, like your background or controlling actor, have a rule that says:if attribute game.Count ≤ 0
The same box can't be hit twice because the boolean is being changed from active to inactive. You could add a destroy actor behavior or move actor behavior to the boxes very simply as well.
---Do something (like change scene or whatever)
Unless you want the game to know exactly which box is been pressed at any given time or what order they are pressed in. But its unclear what you are trying to do here.
Answers