Tracking character by touch beyond screen size
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
"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
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