How do I get position of player on screen/canvas?

Get help using Construct 2

Post » Sat Mar 19, 2016 12:24 am

Hei!

Is there a way to get the coordinates of a object eg. my player on the canvas?

Lets say my canvas is 720x480 pixel. My player is standing on pixel 196,64 which would be top/left of the canvas.
How to get these values into the code? :? :mrgreen:


Greetings!
B
3
Posts: 7
Reputation: 189

Post » Sat Mar 19, 2016 12:57 am

let's say you want to set an some_object to the obj_player
add action > set position x=obj_Player.X y=obj_Player.Y

So you have a lot of options like setting a variable, ...

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Sat Mar 19, 2016 1:06 am

Use the system layer expressions. For example you can subtract viewportleft from player.x to get the player's position relative to the viewport.

https://www.scirra.com/manual/126/system-expressions
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Sat Mar 19, 2016 2:34 am

+1

Thanks you! ViewPort was the keyword for me. ;)
B
3
Posts: 7
Reputation: 189


Return to How do I....?

Who is online

Users browsing this forum: Nicolas951, rayolf and 24 guests