Actor collisions with moving actors via touch

Hi,

I have two platforms (actors) on screen which can be moved/dragged using touch. They are used to bounce a ball up the screen, the left platform when ball collides bounces ball up and right and Right Platform bounces ball up and left. These platforms can be dragged anywhere around screen. The problem im facing is that when i drag one platform through the other, one seems to disapear or lie behind the other. I tried putting a collison on but, it then changes the angle of the platforms, (i need them to stay horizontal) or they stick together one above the other.

What im wanting to do in the perfect world is if i dragged the right platform through the left platform, the left platform just drops below a little or something like that. Obviously if they're at the bottom of screen i dont want the one dropping below to drop off screen.

Can someone please help me.

this is what im using to move platform.

When touch is inside.
DO - constrain attribute - self posiiton.x to game.touches.Touch 1.x
DO - constrain attribute - self position.y to game.touches.Touch 1.y

Best Answer

  • wcsd9739wcsd9739 Posts: 37
    edited February 2015 Accepted Answer

    For your problem with being able to drag off-screen, change the rule you shared before to something like this:

    If Touch is Pressed, Constrain attribute [ self.position.x ] to [ max(min(game.touches.Touch1.x, game.displaysize.width+self.size.width), -self.size.width) ] Constrain attribute [ self.position.y ] to [ max(min(game.touches.Touch1.y, game.displaysize.height+self.size.height), -self.size.height) ]

    Disclaimer: I have not tested this so don't murder me if it don't work :naughty:

    This should make it so the actor will only follow the touch as long as the actor will remain on-screen. If you want the actor to be able to go half off-screen, then replace anywhere where I said "self.size.width" with 0.

    As for bouncing, Constraining the position overrides any collision attributes. So you'll have to use a fancy Move behavior. Here's a link to a post where I posted how to do this: forums.gamesalad.com/discussion/comment/516453/#Comment_516453
    Just scroll down until you reach the longish post by me, with pictures.

Answers

  • Adamuk82Adamuk82 Member Posts: 4

    I've nearly solved this. Ive added a collision on like i noted above but before it was changing the angle of the platform, to solve this ive changed the property of each platform to be fixed position. This lets them knock into each other and they move to the side. Only two problems I have now is that you can push it off screen which I don't want. I have walls but the collision doesnt seem to work when your pushing the actor ? and because your using touch if i push really fast with one platform over another they both get touched and only seperate when i leave go. I guess i need to make if im touching one platform the other should be in-active. Any ideas how to do that?

  • Adamuk82Adamuk82 Member Posts: 4

    Thanks for the reply. Im not quite sure how you write the self.postion changes you have suggested ?? I do that by picking the options, Do i use all the forms of brackets you have put? I can select game.touches.touch1.x ....do i then write a comma after that then select game.displaysize.height ...then write a + then select self.size.width, etc etc. Also the start has [max(min( ...... im just confused how I format this.

    Sorry, new to this.

    I'll check out the bouncing post as well. Thanks.

  • Adamuk82Adamuk82 Member Posts: 4

    Ive tried your second part and it works a treat. Thanks very much. The first part i don't need to do now as you don't seem to be able to drag it off screen now. So it all seems to be working. Thanks very much for your time. Really appreciate it.

Sign In or Register to comment.