Destroying Objects Off-Screen At A Specific Point

Get help using Construct 2

Post » Sun Aug 27, 2017 10:34 am

I'm trying to do some basic optimisation for my endless runner where platforms are destroyed once they leave the play area. I can't use the Destroy When Outside of Layout behaviour because they spawn outside of the layout to give the impression that they're seamlessly scrolling into view. Additionally, my player is continually moving right with a simulated platform behaviour (with a camera which scrolls with it), so the world's X value is continually increasing which makes it hard to determine a specific coordinate value to destroy the platform.

I feel like I'm missing a really simple solution here. I have been able to create an basic anchored sprite which kills the platforms off-screen when they collide with this, but I don't really like this and would rather use something position-based. Ideally, I want to do the same for any other objects/enemies that leave the screen on the left. Any help would be appreciated!
B
5
Posts: 10
Reputation: 245

Post » Sun Aug 27, 2017 1:14 pm

Give them a variable called something like hasBeenOnScreen that's set to 1 when the platform is on screen (Size & Position > Is On Screen) - later have an event that destroys the platform outside of layout if hasBeenOnScreen=1

Alternatively, assuming your player is constantly on the left hand side of the screen fixed in place, you can destroy the platforms when their position relative to the player is -x a certain amount.
B
62
S
23
G
10
Posts: 648
Reputation: 10,580

Post » Sun Aug 27, 2017 9:25 pm

if Object.X < ViewportLeft(Self.LayerName)-(object.width/2) => destroy

This way the object will get destroyed only if its on the left "off-screen".
Image
B
9
S
2
G
1
Posts: 36
Reputation: 643

Post » Mon Aug 28, 2017 4:10 pm

Thanks to both of you, I managed to get this working! Cheers!
B
5
Posts: 10
Reputation: 245


Return to How do I....?

Who is online

Users browsing this forum: tannerdler and 28 guests