going from a scrollable position to a nonscrollable position?

Ran into a little problem today, i want to spawn an item into a scrollable layer and then have that item interpolate to a nonscrollable layer(the HUD). Im making an rpg and when the player collects a resource, I want to spawn the item from the node(scrollable layer) and interpolate its position to your inventory which is a nonscrollable layer. the problem is the grid coordinates (350,820) mean something different to the nonscrollable layer than to the scrollable layer..
Any help would be greatly appreciated!

Best Answer

  • kobayaashikobayaashi Posts: 143
    Accepted Answer

    Would it not be possible to gauge the position of the resource relative to the current camera position, interpolate to the location the resource would appear on the hud, then spawn a version on the hud layer while destroying the original? Or am I way off base..?

Answers

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited January 2016

    Can't do it. For one even if both layers were the same you can't switch layers period. Matching a hud layer with a scrollable is impossible.

  • Shenanigans StudioShenanigans Studio Member, PRO Posts: 73

    @kobayaashi no you are definitely onto something! Im gonna play around with that idea, think it should work!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @kobayaashi said:
    Would it not be possible to gauge the position of the resource relative to the current camera position, interpolate to the location the resource would appear on the hud, then spawn a version on the hud layer while destroying the original? Or am I way off base..?

    That's what I was thinking, too...

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2016

    This is actually pretty simple. Have the actor on the scrollable layer change a game attribute (I used a boolean) and then have an actor on the non-scrollable layer spawn an actor relative to itself or relative to the scene when that attribute changes value.

    The attached demo was made in Mac Creator. Click to spawn.

    Edit: see the demo attached to the post below.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2016

    It needs a few more things to do exactly what you described... I'll see if I can add them.

    Edit: Hmm... having the scrollable actor spawned means that you can't access the camera controls. But I think I can work around that...

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2016

    This is a little off, position-wise, but close!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2016

    There's an offset of about 177 pixels horizontally (x) and 135 pixels vertically (y) between the click location and the spawn location. I'm not sure what that's about but I just manually adjusted the spawn location. So my best effort is this (demo attached):

  • ArmellineArmelline Member, PRO Posts: 5,415

    Fun!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Lookin' good, @Armelline. I haven't checked out the file yet but how did you solve the offset issue I ran into?

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @Armelline said:
    Fun!

    Very seamless.

  • ArmellineArmelline Member, PRO Posts: 5,415
    edited January 2016

    @tatiang said:
    Lookin' good, @Armelline. I haven't checked out the file yet but how did you solve the offset issue I ran into?

    I'm not sure. I just didn't encounter it :D What I suspect is the case is this:

    The scrolling items are on a scene-wide X position. So if the camera has been moving a while, they might be at self.position.X 2500. The spawner, however, is on a screen-wide X position. So if the object is at self.position.X 2500, the spawner needs to spawn the object at 2500-camera.origin.X.

    A non-scrollable layer always has 0 as the left of the screen and (in this case) 1024 as the right. No matter where the camera has moved to.

Sign In or Register to comment.