Tracking character by touch beyond screen size

iKandyiKandy Imagineer of Crazy ShitNew York CityMember Posts: 310
edited May 2012 in Working with GS (Mac)
This was an old thread that wasn't sufficiently answered.
"Bladeolson" asked how to have touchX go beyornd the original screen coordinates when using the camera.
"Firemaplegames" answered the question, but only partially....

You need to account for the camera offset.

Create two global game attributes, cameraX and cameraY

Create a "cameratracker" actor. Just a simple box will do. No code in the prototype.

Drag this actor into the Scene, just offscreen. Double click on it (and the padlock) to access the Scene Attributes.
Only Instances can access Scene Attributes. Constrain Scene.Camera.OriginX to game.cameraX and Scene.Camera.OriginY to game.cameraY

Now you have access to the camera origin (the lower-left corner of the screen at all times)

You'll need to add cameraX to TouchX to get the correct Touch position.

The final sentence above, wasn't really explained and several people on the thread asked for an explanaion.

Firemaple games... can you explain the last sentence.... thanks


Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited May 2012
    in the move to touch rules or whatever your usign the touch for make sure its touch.x+camera.x instead of just touch.x
  • Max3DMax3D Member Posts: 6
    edited May 2012
    I am using something similar to this in my project at the moment.

    Just to test add an Accelerate Towards behavior to controllable actor, in the [Position >] set it to [game.Touches.Touch 1.X + game.cameraX] and in the [Position ^] set it to [game.Touches.Touch 1.Y + game.cameraY]. Set Relative to: to Scene and set Acceleration to a value that is good for you.

    The [ ] are just to help readability, they are not needed in the code blocks.

    This should work I believe.

    EDIT: This is what I used to learn originally :

    Max3D
  • iKandyiKandy Imagineer of Crazy Shit New York CityMember Posts: 310
    OK, thanks Guys... solved my issue.
Sign In or Register to comment.