Overlapping at offset - classic vs construct 2 equivalent

0 favourites
  • 7 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Hello, I hope someone can assist with my question..

    I have been porting over a game from Construct Classic to Construct 2, but I am having difficulty parsing a "collision at offset" condition to C2

    My CC condition offset condition looked like this

    X : (ScrollXLeft*(100-LayerScrollRateX(.Layer))/100)

    Y : (ScrollYTop*(100-LayerScrollRateY(.Layer))/100)

    But as C2 doesnt have ScrollXLeft, scrollXTop and the ScrollRate references, I'm a bit lost - can anyone please assist with helping me find the equivalent offset, plus the new syntax?

    I'd be extremely grateful for any help, this is one of the final steps to getting the old engine running again..

  • There are only a few expressions in C2 related to scrolling - ScrollX, ScrollY, LayerParallaxX and LayerParallaxY.

    And, as far as I know, there is no such thing as scroll rate.

    I'm not sure how any of those can be related to "overlapping on offset" (there is no "collision at offset" either).

    Are the objects that you need to check for overlapping located on layers with different parallax setting?

  • dop2000 Yes, I need to check for overlapping located on layers with different parallax setting..

    Iam also realising I need to figure out how to fire a bullet from an object on a parallax layer , at the position of an object on a non paralaxxing layer.

    I am having to do this because I can't find a way to get a single player sprite on a layer with parallax to ignore the parrallax..

    I tried an anchor, and attempted to base the sprite movement from the anchored origin, but it vibrates when certain scroll criteria occur - I also attempted to use divided window sizes with no clean results.

    I've spent a whole day trying to get a solution, but the only way I can do it smoothly it seems is to use a new layer with no parrallax and deal with all the offset mess..

  • I found a few posts that could help:

    Edit: this is how you convert coordinates from layer 1 to layer 0 (when sprite located on layer1):

    CanvasToLayerX("Layer 0",LayerToCanvasX("Layer 1", sprite.X, sprite.Y) ,LayerToCanvasY("Layer 1", sprite.X, sprite.Y))

    CanvasToLayerY("Layer 0",LayerToCanvasX("Layer 1", sprite.X, sprite.Y) ,LayerToCanvasY("Layer 1", sprite.X, sprite.Y))

    For example, to fire a bullet from gun on layer 2 at player on layer 1:

    Create object Bullet on layer 1,

    set X to CanvasToLayerX(1, LayerToCanvasX(2, Gun.X, Gun.Y), LayerToCanvasY(2, Gun.X, Gun.Y))

    set Y to CanvasToLayerY(1, LayerToCanvasX(2, Gun.X, Gun.Y), LayerToCanvasY(2, Gun.X, Gun.Y))

    Set Bullet angle of motion to angle(bullet.X, bullet.Y, Player.X, Player.Y)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000 Thanks hugely for your prompt replies.. expect a paypal donation when I get some funds!..

    I tried the coordinate conversion earlier today.. I placed an object on my zero parallax HUD layer (hudlayer) that is set to the center of the screen, then applied this to an object on my "action layer" to create a non moving reference for my player sprite to move from..

    Origin center : set x CanvasToLayerX("action",LayerToCanvasX("hudlayer", screencenter.X, screencenter.Y) ,LayerToCanvasY("hudlayer", screencenter.X,screencenter.Y))

    the player sprite is controlled thusly :

    origin center.X+P_HitBox.P1XPos

    the p1xpos is incremented/decremented by a speed variable when a key is held in a specific direction.

    however when the scroll changes direction on the X, the position of the Origin center still wobbles.

    I'm not updating the Y position at all as it is not needed for this particular application.

  • I'm not sure I understand.. Could you share you capx? (you can PM it to me)

    Or create a small project that demonstrates the problem?

    By the way, if I'm not mistaken, screen center on a layer with parallax 100,100 is always at (scrollx, scrolly)

  • dop2000 I am still trying to do this without placing the sprite on its own zero parallax layer for now, as it seems to have less ramifications.

    I will build a minimal cap as soon as I get a chance, the current one contains way too much content.

    Thanks again.

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