How to make a hit box?
![jobei](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
I want to touch a image on the right side of the screen making another image to pop up on the left side of the screen.
Best Answers
-
tenrdrmer Posts: 9,934
@jobei
Stop Rejecting answers just because you don't understand them. This thread is being dropped from a Q@A to a discussion due to your misuse of the feature. you have had 2 different ways explained and both are useable ways of doing this. If your not understanding them then you need to think about taking a step and watching some more tutorial videos to get a better grasp on how gamesalad works.
Answers
if touch is pressed change attribute game.ButtonPressed to true.
In you second action you would put a rule:
if attribute GameButtonPressed is true .... and then you have a number of choices.
1. The actor could be in the spot you want it but with its Alpha set at 0 (ie: transparent) then the rule would change attribute self.color.alpha to 1
2. You could have the second actor off scene and the rule would trigger it either sliding in (interpolate) or just jumping instantly to the position you want by changing it's x and Y position
I want to make a small box over top of a big actor image. So when i touch the box the second actor pops up in the same spot.
Im not sure if we can do that tho?
Let try this, I have two actors on my screen right now. actor A and actor B . I set it up already were actor A is on the left side of the screen and actor B is on the right. I want to be able to touch actor A and that will make actor B destroy.
If this work right I should be able to move actor A all around the screen and when I touch it, it will always destroy actor B.
Can anyone help me with this code? :P
1. Create a game attribute (boolean) called "hit"
2. Inside actor A, create a rule that says:
When all of the following is true:
Touch is inside
constrain attribute: self.position.x to devices.mouse.position.x
constrain attribute: self.position.y to devices.mouse.position.y
change attribute: game.hit to true (spell it out :P)
3. Now, inside actor B, create a rule that says:
When all of the following is true:
game.hit (attribute) is true
Destroy this actor.
Hope this gets you the result you want!
When I make my rule it say "When all following is happening." it don't say "When all the following is ture" Is that the main reason why it don't work?
Inside actor A I created a rule:
When all of the following are happening: (then i drag attribute into the rule and it turn into "If " with a empty box in front of it) (Then I made a "boolean" and named it "hit")
if self.hit is true:
touch is inside:
do:
constrain Attribute:
constrain: self.position.x
to: self.touch.position.x
constrain Attribute:
constrain: self.position.y
to: self.touch.position.y
(I made all the constrain attribute under "boolean")
Inside actor B I created a rule:
When all of the following are happening:
if self.hit is true:
do:
destroy:
Then when I go to play the screen, actor B is already gone with out me touching actor A to set off the action to destroy actor B.