Help with Spawn and Destroy Objects - Faster Game on Mobile

Get help using Construct 2

Post » Fri Dec 16, 2016 9:26 pm

Hey folks, I'm making a mobile game where the player is always walking on a long layout, 6000px X 293px, and it can only jump. I want to add obstacles but when I placed everything where I wanted to be at, it ran slow on mobile, and I understand this is because the system is loading everything at once...

So what I cant figure out is how to spawn the obstacles, which are 3 different ones and they should appear on different positions of the layout...

I tried to create an Object that when the player would colide with it, it would spawn the obstacle at a certain image point (in front of the player). This kinda works, but since the player can jump it would spawn the object on different areas where they shouldn't be...

So I need help to set up an event where when the player touches this Object, it will spawn the obstacle always at the same height ahead of the player... even if it jumps...

I also need help to set up an event where a family of objects will be destroyed after it passes the player, like 300px away to the left...

I'm sure this should be simple, but I'm just kind of a noob ;)

Thank a lot for anyone who can guide me.
B
19
S
9
Posts: 75
Reputation: 1,717

Post » Sat Dec 17, 2016 2:18 am

Hey mate,

Are you using the auto-runner template? How does that run with your mobile without any changes made?

What you want to do is, when the game first starts load all of your obstacles in and then delete them before the game starts moving (This loads them into memory and should help avoid jank on creation).

Your family of obstacles can have an event where you 'compare the X' value in the condition. Is it less than your 'player sprite' minus 300? If so destroy it.
ImageImage
B
130
S
23
G
7
Posts: 1,078
Reputation: 13,280

Post » Thu Dec 22, 2016 4:10 am

Hi @GenkiGenga I am not using an auto-runner template, I have set the level as I wanted, not creating "at random". It is going left on every tick (plataformer)

I will try your solution for the "X comparison", thanks a lot
B
19
S
9
Posts: 75
Reputation: 1,717


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests