Drag multiple objects at once

RodrigoPerezRodrigoPerez Member Posts: 212
edited November -1 in Working with GS (Mac)
I have a game I'm working on that requires getting a bouncing ball into a goal by rotating platforms to the correct angles. I currently have it set up to where these platforms can rotate by dragging them with a touch, however when I'm rotating one platform and then simultaneously use another finger and try to rotate another platform it doesn't register. Thank you in advance.

Comments

  • POMPOM Member Posts: 2,599
    You need to use multi touch, cause the game engine needs to figure out which touch is touching each platform.
    if its your first time messing with multi touch i suggest you take a look at the Joystick control template as a start.

    Roy.
  • RodrigoPerezRodrigoPerez Member Posts: 212
    Does it matter that all the platforms are duplicates of the same actor?
  • RodrigoPerezRodrigoPerez Member Posts: 212
    I studied CodeMonkeys Joystick tutorial, however I'm having trouble implementing that into my project. Because the joystick tutorial is using buttons to control another actor. While I'm trying to use multitouch using having direct contact with the platforms. An example would be if there are three flat platforms and I wanted to use three fingers to rotate them by dragging each one all at the same time, but also having the flexibility to; if needed rotate just one with one finger how would I go about that?
  • POMPOM Member Posts: 2,599
    What is the rule for the rotation?

    Roy.
  • RodrigoPerezRodrigoPerez Member Posts: 212
    When Actor receives : touch : is : pressed

    Change Attribute
    self.initRotation : to : self.rotation

    Change Attribute
    self.initAngle : to : vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )

    Constrain Attribute
    self.myAngle : to : vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )

    Constrain Attribute
    self.Rotation : to : self.initRotation +( self.myAngle - self.initAngle )
  • POMPOM Member Posts: 2,599
    Ok so first thing first , when you use multi touches method you should not use mouse position , you need to use Touch.1.X , Touch.2.X ect.

    BUT ! to make the game understand which touch is touching which platform , and what happen if you put 1 finger , then add finger 2 , AND then remove finger 1 ect , you need to add some bit complicated rules ,
    so the way i suggest is to create 3 actors , "Touch1", "Touch2", "Touch3" , each one constrain only to its touch.

    And in the platforms make a collision rule:
    If collide with actor "Touch1"
    Change Attribute
    self.initRotation : to : self.rotation

    Change Attribute
    self.initAngle : to : vectorToAngle( game.Actor.Touch1.X - self.Position.X , game.Actor.touch1.Y - self.Position.Y )

    Constrain Attribute
    self.myAngle : to : vectorToAngle( game.Actor.Touch1.X - self.Position.X , game.Actor.touch1.Y - self.Position.Y )

    Constrain Attribute
    self.Rotation : to : self.initRotation +( self.myAngle - self.initAngle )
    -----------------

    If collide with actor "Touch2"
    Do the same but with the coordinates of the actor "Touch2"

    And so on.

    I hope it helps you mate.

    Roy.
  • RodrigoPerezRodrigoPerez Member Posts: 212
    Thank you for the help. I don't know why but I'm just not grasping this. Is there a demo that shows this behavior?
Sign In or Register to comment.