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

0 favourites
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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?

  • 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.

  • 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?

  • 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.

    [quote:2tu7c88c]Understand the picking of newly created/spawn instances since R101 - LINK

    as per the How do I FAQ

  • 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.

    [quote:2x09wlyx]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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You want the viewport expressions.

    [quote:29zn3ugk]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.

  • You want the viewport expressions.

    [quote:njsazsfi]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?

  • 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.

  • 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

  • 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

  • I have been meaning to check out LiteTween lately - but I've been finding it just as easy to do them manually - so I'm not sure exactly what results you're getting.

    When you say "it does work, but not with the plugin" what do you mean? What part works and what part doesn't?

    If it's moving to the position, but then it's kind of "floating" around when you move - that's easy to solve. If it's something else, then try to explain specifically.

    ~Sol

  • Also consider that a third-part addon may have issues, and in that case you may need to report it in the official topic for the addon.

  • I have been meaning to check out LiteTween lately - but I've been finding it just as easy to do them manually - so I'm not sure exactly what results you're getting.

    When you say "it does work, but not with the plugin" what do you mean? What part works and what part doesn't?

    If it's moving to the position, but then it's kind of "floating" around when you move - that's easy to solve. If it's something else, then try to explain specifically.

    ~Sol

    I got angry, so I decided to see if the viewpoint expression you gave me actually worked. So I made that if I clicked L, it would spawn that Heart at:

    X: ViewportLeft(0)+45

    Y: ViewportTop(0)+452.5

    And that worked. But Litetween doesn't take expressions, so I turned to variables, but that didn't help, either.

  • Also consider that a third-part addon may have issues, and in that case you may need to report it in the official topic for the addon.

    Kyatric

    Okay, I might try posting a comment to them.

  • You just set the LiteTween X & Y explicitly. You can use expressions if you want.

    http://www.blackhornettechnologies.com/ ... Tween.capx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)