How do I make an object go to an x, y of the screen?

Get help using Construct 2

Post » Wed Aug 10, 2016 1:59 am

I know how to make an object move to a certain x, y, But I have a player that is able to move around on the screen, so if I told an object to move that the player spawns in with that specific x, y coordinates, it would go there and not be on the player's screen.
Is there any special type of x, y coordinates that are used for the screen?
*Insert Signature here*
B
13
S
5
Posts: 73
Reputation: 1,090

Post » Wed Aug 10, 2016 4:06 am

I saw something Sol posted about the layertocanvas or canvastolayer expressions. I haven't been able to use it yet myself, but I think that's what you want.
Eh, Steve!
B
113
S
54
G
13
Posts: 112
Reputation: 16,090

Post » Wed Aug 10, 2016 7:37 am

calebbennetts wrote:I saw something Sol posted about the layertocanvas or canvastolayer expressions. I haven't been able to use it yet myself, but I think that's what you want.


@calebbennetts

Erm, seems I have to learn how this works...Is there a Alternative way, though?
*Insert Signature here*
B
13
S
5
Posts: 73
Reputation: 1,090

Post » Wed Aug 10, 2016 9:23 am

Why search an alternative to the system expressions that are exactly doing what you are attempting to do and requiring ?

Also I'm confused by what you said : "so if I told an object to move that the player spawns in with that specific x, y coordinates, it would go there and not be on the player's screen."

Could you detail exactly, and in order, what you are doing, what you are attempting to do, what you'd expect to do and what you are currently experiencing ?
Posting a capx is not a bad idea either.

You mention spawning something.
Understand the picking of newly created/spawn instances since R101 - LINK
as per the How do I FAQ
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Thu Aug 11, 2016 2:02 am

Kyatric wrote:Why search an alternative to the system expressions that are exactly doing what you are attempting to do and requiring ?

Also I'm confused by what you said : "so if I told an object to move that the player spawns in with that specific x, y coordinates, it would go there and not be on the player's screen."

Could you detail exactly, and in order, what you are doing, what you are attempting to do, what you'd expect to do and what you are currently experiencing ?
Posting a capx is not a bad idea either.

You mention spawning something.
Understand the picking of newly created/spawn instances since R101 - LINK
as per the How do I FAQ


@Kyatric

I'll explain.
I'm trying to make some Undertale fangame, so I'm trying to make that heart thing when you encounter a battle go in a specific spot in the screen. The problem is, I don't know the expression for the X and Y of the screen, just regular X and Ys.
The Regular X and Y that I'm using for the heart to move to is: 45, 452.5

Here is a video to explain my problem: https://drive.google.com/file/d/0Bw7SYAAkapF1MFJrQnpfa2YtMGc/view

On the first section of the video, it shows where the heart is supposed to move on to the screen, after I refreshed the page, I moved away from that section of the layout, and then the heart went to those regular coordinates.

I'm trying to ask is, Is there a expression I can use so I can move that heart over to that section of the screen, like the X, Y of the Screen?
*Insert Signature here*
B
13
S
5
Posts: 73
Reputation: 1,090

Post » Thu Aug 11, 2016 3:54 am

You want the viewport expressions.

ViewportBottom(layer)
ViewportLeft(layer)
ViewportRight(layer)
ViewportTop(layer)
Return the viewport boundaries in layout co-ordinates of a given layer. Not all layers have the same viewport if they are parallaxed, scaled or rotated separately.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Thu Aug 11, 2016 7:55 am

oosyrag wrote:You want the viewport expressions.

ViewportBottom(layer)
ViewportLeft(layer)
ViewportRight(layer)
ViewportTop(layer)
Return the viewport boundaries in layout co-ordinates of a given layer. Not all layers have the same viewport if they are parallaxed, scaled or rotated separately.


@oosyrag
But how do I make it on a specific coordinate of the layer?
*Insert Signature here*
B
13
S
5
Posts: 73
Reputation: 1,090

Post » Thu Aug 11, 2016 10:08 am

LayerToCanvasX(LAYER, X, Y)

LAYER = Layer where your "Fight" Heart is
X = X position of your "Fight" Heart in the layer "LAYER"
Y = Y position of your "Fight" Heart in the layer "LAYER"

Same for LayerToCanvasY

And both those are to be the destination position coordinates for the heart you spawn and move when you go into battle.
In relation with its current position on screen/canvas as well.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Thu Aug 11, 2016 10:08 am

The Canvas2Layer and Layer2Canvas thing I was talking about is more specifially used to track objects between varying layers of parallaxing. For example in my project I have a light source on a parallaxed layer, but the object that gives the illusion of it actually being "light" is on a non-parallaxed layer. I had to make the "light" follow the source between the varying parallax values... so this is the use of Layer2Canvas and Canvas2Layer.

@UltimateArceus3

If you set your heart to something like:
heart.x = ViewportLeft("whatever layer name or number")+5
heart.Y = ViewportBottom("same layer name or whatever as above") -5

It will place the heart at 5px from the left and 5px from the bottom of the current layer (UI layer?) and always stay there no matter where the player moves to.

*EDIT*
@Kyatric ninja... ninja, RAH!

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
80
S
34
G
40
Posts: 3,029
Reputation: 30,393

Post » Thu Aug 11, 2016 10:53 am

SoldjahBoy wrote:The Canvas2Layer and Layer2Canvas thing I was talking about is more specifially used to track objects between varying layers of parallaxing. For example in my project I have a light source on a parallaxed layer, but the object that gives the illusion of it actually being "light" is on a non-parallaxed layer. I had to make the "light" follow the source between the varying parallax values... so this is the use of Layer2Canvas and Canvas2Layer.

@UltimateArceus3

If you set your heart to something like:
heart.x = ViewportLeft("whatever layer name or number")+5
heart.Y = ViewportBottom("same layer name or whatever as above") -5

It will place the heart at 5px from the left and 5px from the bottom of the current layer (UI layer?) and always stay there no matter where the player moves to.

*EDIT*
@Kyatric ninja... ninja, RAH!

~Sol


@SoldjahBoy

It does work, but I can't make it work with the plugin I'm using that makes it move to that position.
The plugin I'm using is LiteTween.
Here's the link:
https://www.scirra.com/forum/behavior-litetween_t70700
*Insert Signature here*
B
13
S
5
Posts: 73
Reputation: 1,090

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests