Would it be possible to have a rectangle touch recognition add on to an actor?
Tiny_Ideas
Member Posts: 326
Hello all,
Not really sure how to explain this using words, so everything below is based off this picture:
http://www.google.com.au/imgres?client=safari&hl=en&tbm=isch&tbnid=FwhZy6gQkHR3pM:&imgrefurl=http://www.quickanddirtytips.com/education/math/what-is-the-distributive-property&docid=INjnibzp0fKrSM&imgurl=http://www.quickanddirtytips.com/sites/default/files/styles/insert_large/public/images/2170/MD043-fig1.png%3Fitok%3DeQiIL1hN&w=673&h=302&ei=zUbrUsD3M4rQlAWXjYCgDQ&zoom=1&ved=0CG4QhBwwFQ
The lighter shade square, A,B is the actor. Because it is so small, its difficult to get a touch to register. It needs a bigger touch base. Making the actor longer will not work because the collision of the actor is based on size of the square. Not a rectangle.
Initially, I created an attribute within side the actor called self.Distance and set it to 100. I then set a rule that if self.distance is equal to or less than the magnitude(touch.x-self.positionx, touch.y-self.position.y) than its a touch.
This is all fine if the actor was moving up,down,left or right. But the actor has a 360degree movement.
What currently is happening is that because it's based on the actors positions, which are the centre of the actor, the radius can be a complete circle around it.
I need a way to make it so touch is only registered within the rectangle, and the rectangle can go both ways equally of the actor, only forward and backwards relative to the actors rotation, if that makes it easier for a function because I can than have a rule that the actor has to be facing forward.
Even if there is away to make it so the rectangle is on November sides of the square would be great. Just trying to control the area.
Hopefully that makes some sense.
Thanks
Not really sure how to explain this using words, so everything below is based off this picture:
http://www.google.com.au/imgres?client=safari&hl=en&tbm=isch&tbnid=FwhZy6gQkHR3pM:&imgrefurl=http://www.quickanddirtytips.com/education/math/what-is-the-distributive-property&docid=INjnibzp0fKrSM&imgurl=http://www.quickanddirtytips.com/sites/default/files/styles/insert_large/public/images/2170/MD043-fig1.png%3Fitok%3DeQiIL1hN&w=673&h=302&ei=zUbrUsD3M4rQlAWXjYCgDQ&zoom=1&ved=0CG4QhBwwFQ
The lighter shade square, A,B is the actor. Because it is so small, its difficult to get a touch to register. It needs a bigger touch base. Making the actor longer will not work because the collision of the actor is based on size of the square. Not a rectangle.
Initially, I created an attribute within side the actor called self.Distance and set it to 100. I then set a rule that if self.distance is equal to or less than the magnitude(touch.x-self.positionx, touch.y-self.position.y) than its a touch.
This is all fine if the actor was moving up,down,left or right. But the actor has a 360degree movement.
What currently is happening is that because it's based on the actors positions, which are the centre of the actor, the radius can be a complete circle around it.
I need a way to make it so touch is only registered within the rectangle, and the rectangle can go both ways equally of the actor, only forward and backwards relative to the actors rotation, if that makes it easier for a function because I can than have a rule that the actor has to be facing forward.
Even if there is away to make it so the rectangle is on November sides of the square would be great. Just trying to control the area.
Hopefully that makes some sense.
Thanks
Comments
Another chance to pimp my Link Machine
http://forums.gamesalad.com/discussion/62202/linkmachine
But if I could brake it down smaller, is it possible to find the edge of a side of the actor.
Example. Actor is 50x50 and is placed at 100x, 100y.
The side position would be, 100x, 150y.
Or 100x, 50y.
That is going to give me one side, which is all I need. But can I still find it if the actor has rotated.
Would that be possible?
Because if you can constrain an actor, I should be able to constrain the value.?
As much as it pains me to say it, I agree that the Link Machine is your best bet.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
If I understand your description correctly then 100 X / 150 Y would describe a pixel located 25 pixels (centred) above the top edge of the square.
And 100 X / 50 Y would describe a pixel located 25 pixels (centred) below the bottom edge of the square.
I'm not 100% sure what the question is, it's a little vague, could you state it in basic terms, 'find the edge of the side' and 'this [will] give me one side' is too ambiguous for me (probably need more coffee ) not sure what 'find' means here (detect as in overlap or collide ? Or measure in some way ?), can you put it in terms of 'I want to work out the distance to . . . .' or 'I want to know the angle of . . . ' that kind of thing ?