How do I have an object act as though in the UI

Get help using Construct 2

Post » Fri Aug 26, 2016 5:09 pm

The pointer has 8 direction control (the yellow circle). The gun has its angle set towards it. In the UI it doesnt work, so the circle is on normal game layers. But I need it to be confined to the screen, and to not move when the player moves. basically to act like it is in the UI. Unless theres a way to have it on the UI layer and get the angle to it properly?
Thank you!

Image
- Head of Tall Story Studios.

Creator of GOV, Project Abyss, Spiritlands & more!
B
27
S
12
G
2
Posts: 129
Reputation: 3,169

Post » Fri Aug 26, 2016 9:18 pm

You can use CanvasToLayer and LayerToCanvas to get the X Y of an object on a different layer

example

CanvasToLayerX("UI",LayerToCanvasX("game",object.x,object.y),LayerToCanvasY("game",object.x,object.y))
CanvasToLayerY("UI",LayerToCanvasX("game",object.x,object.y),LayerToCanvasY("game",object.x,object.y))
Image
B
82
S
30
G
12
Posts: 517
Reputation: 12,763

Post » Fri Aug 26, 2016 10:12 pm

another way is to use the pin behavior and pin the yellow circle to the player.
Everytime you are moving the circle on its own you disable the pin > do what ever movement you want > and repin it.
something like this
Image
B
73
S
30
G
7
Posts: 86
Reputation: 7,653

Post » Fri Aug 26, 2016 10:20 pm

Not sure that's a good idea, because if its on the game layer you will need to send it to the top with every new object you spawn on that layer and if you going to scale in/out the game layer, you'll probably want the crosshair to stay the same size, not to mention it's unnecessary extra events and behaviors.
Image
B
82
S
30
G
12
Posts: 517
Reputation: 12,763

Post » Fri Aug 26, 2016 11:42 pm

Thanks! Will try :)
- Head of Tall Story Studios.

Creator of GOV, Project Abyss, Spiritlands & more!
B
27
S
12
G
2
Posts: 129
Reputation: 3,169


Return to How do I....?

Who is online

Users browsing this forum: work3 and 7 guests