How to spawn an object, but always on different imagepoint

Just started using Construct 2? Post your questions here

Post » Sun Oct 19, 2014 3:00 pm

@j0schi - The more objects you create and spawn, the more the cpu is used. Take an infinite runner game for example, particularly temple run. There is an infinite board and there are a serious of 10 or so coins to collect in spurts the entire way. If you were to create the random board (which is needed in that type of game) and create new coins after each one is collected (my ex-boyfriend's daughter hit over a million coins collected and she's only 8) that would use well over 50% of the cpu. At the very least and that's far more taxing than any program should be.

But...if you just move the same 10 coins or 20 coins as they are being collected, the player will never notice the move and it'll save the fps and cpu.

@Kyatric offers this link in @ddaan9 's post about spawning vs. visibility
https://www.scirra.com/blog/112/remember-not-to-waste-your-memory

Then again...if you're only creating a couple objects and you never destroy them , your cpu and fps rate probably won't even budge.
B
10
S
1
Posts: 67
Reputation: 909

Post » Mon Oct 20, 2014 12:48 am

@iwontnamemyself thanks for the clarification. what i thought was that when a object is destoyd (bullet hit enemy OR enemy is not in layout -> enemy destroy ) would to the trick and memory / CPU is free for other objects to spawn... my game spawns far more than 8000 objects and they get destroyed after leaving the layout or when they get hit by a bullet... and i ran in no troubles.

when i didnt destroy the bullets outside of the layout however the load bagan to rise, which is normal.

so i will run another test and spawn 8000 objects and will look at the memory/cpu if it will have any impact.

regards
joschi
B
19
S
7
G
1
Posts: 222
Reputation: 2,546

Post » Tue Oct 21, 2014 3:56 am

j0schi - Do you have over 8000 objects on the screen at one time, or are you spawning 8000 objects over the course of the game?

May I suggest, if it's possible, to turn the visibility off and add a visibility check before anything is suppose to interact with them. That way, all your code only acts when they are visible, so you're not having to create and destroy a ton of objects. Then you can reposition and make them visible again when you need them.
B
10
S
1
Posts: 67
Reputation: 909

Post » Wed Oct 29, 2014 2:26 am

@iwontnamemyself i am spawning over 8000 objects over the course of the game... didnt noticed any impact :)

regards
B
19
S
7
G
1
Posts: 222
Reputation: 2,546

Previous

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests