Would it be possible to have a rectangle touch recognition add on to an actor?

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

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    Getting it to go on November sides will be difficult, I'd just constrain a square actor to a rectangular actor so you can put whatever rules and behaviours you want into each actor, so they will move as one but have different areas for different rules.

    Another chance to pimp my Link Machine :)

    http://forums.gamesalad.com/discussion/62202/linkmachine
  • Tiny_IdeasTiny_Ideas Member Posts: 326
    edited January 2014
    @socks, yeah I been looking at that.

    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.?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Getting it to go on November sides will be difficult
    Lol!

    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

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    is it possible to find the edge of a side of the actor.
    Not too sure what an edge of a side of an actor is ? Do you simply mean the edge ?
    Example.

    Actor is 50x50 and is placed at 100x, 100y.

    The side position would be, 100x, 150y.

    Or 100x, 50y.
    Assuming a square actor . . .

    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.
    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.?
    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 ?
  • Tiny_IdeasTiny_Ideas Member Posts: 326
    edited January 2014
    Edited: never mind, it didn't work
Sign In or Register to comment.