How do I get parallaxed XY of an object?

0 favourites
  • 4 posts
From the Asset Store
Set of 10 Parallax Background to make pixel art game.
  • I'd like to get the Parallaxed coordinates of an object... so in essence, where it's actually drawn on the screen..

    I'm making a minimap and I have some background objects that use parallax 25,25.. I'd like them represented on the minimap.. but they don't line up because of the parallax delay (scrollrate).

    The 'camera' is lerping to position: lerp(scrollx, player.X, 0.9*dt (and same for the Y)

    Can anyone offer a suggestion? I know it's probably not possible with a simple equation since the scrollrate depends on when the player is moving (and how fast). And on a map it wouldn't really accurately say where an object is... but the parallax effect can help make something seem giant or really far away (depth wise) and I still would like to represent it in the minimap.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I am not in front of C2, but maybe the expressions:

    Self.x +(100-LayerParallaxX(Self.LayerName))*WindowWidth/100

    Self.y +(100-LayerParallaxY(Self.LayerName))*WindiwHeight/100

    Would return the actual x and y position relative to the layout

    Edit:replace self by your object name

  • That didn't work...However I failed to mention I'm trying this on an unbound layout.

    So my MiniMap for enemies that are on the same layer as the player is:

    Every Tick Set Position (of Enemy_Indicator) to:

    Player_indicator.X + (alien.X - Player.X) / MiniMapZoom

    Player_indicator.Y + (alien.Y - Player.Y) / MiniMapZoom

    The player indicator I am treating as the "center".. since it's like Zans Minimap (from minecraft). This works perfectly for all object on the same layer. MiniMapZoom is the scale of the map (increments of 10).

    So when you begin the level, the player is not moving and all object's positions are the same distance for all layers. It's not until the player moves does the the Xs grow apart. The drawn parallaxed position would seem to have to include the player's speed or the scroll amount of the screen...

    Something like:

    Every Tick Set Position (of Planet_Indicator) to:

    Player_indicator.X + (Planet.X * (LayerParallax(3) / 100) - Player.X) / MiniMapZoom

    Player_indicator.Y + (Planet.Y * (LayerParallax(3) / 100) - Player.Y) / MiniMapZoom

    but this doesn't work... whatever the calculation is, the modifier would have to equal 0 at the beginning before the player starts moving.. then it would have to accumulate as the player started to move. I've been working on this too long and can't see it... I can feel the answer.. but it eludes me!

  • here is a capx I am working on... the object on the "far away" layer(30,30) is not working right on the minimap...

    https://dl.dropboxusercontent.com/u/362 ... nimap.capx

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