Fireball. Garbage Collection.

Discussion and feedback on Construct 2

Post » Wed Apr 18, 2012 1:54 pm

Hi i was just reading about the Garbage Collection.

In my game you can cast spells.

Right now i am just thinking of, Create Fireball. On hit Destroy Fireball.

But now after reading about Garbage Collection..

1. Should i create the fireball from the start and just make it invisible and move it around?

2. Will the Invisible Fireball affect the Framerate?

3. Is it a bad idea to have the fireball have a tail made of Particles?
B
40
S
11
G
4
Posts: 665
Reputation: 8,403

Post » Wed Apr 18, 2012 5:07 pm

1. C2 already recycles instances for you, and attempts to minimize GC as much as possible automatically for you as described here: http://www.scirra.com/blog/76/how-to-write-low-garbage-real-time-javascript

2. Not unless you have a ton of them and/or you're processing a lot of logic on them.

3. Not at all.Arima2012-04-18 17:11:22
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Wed Apr 18, 2012 5:39 pm

1.Thx 2.Thx 3. Thx



Yes, that is the one i read. But i wasn't sure, because it said that the GC was "reduced".

But if the Recycling is that good, would it be safe to create a fireball every time i cast the spell?
B
40
S
11
G
4
Posts: 665
Reputation: 8,403

Post » Wed Apr 18, 2012 5:42 pm

Sure. It's not like you're going to cast 1000 fireballs a second, right? :P
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Wed Apr 18, 2012 5:42 pm

Plenty - you don't have to worry when creating a few instances. A few hundred or thousand on the other hand, depending on your computer you might start noticing pauses.Arima2012-04-18 17:42:38
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Wed Apr 18, 2012 5:49 pm



Nah probably not a few 1000 ^^

But i might need to cut my game up into quite a few layers hehe.

Do Buildings, trees and other object affect this as well? Things that do get created while loading and don't spawn while playing.


Edit:

I'm reading about the WebGL right now, that should help? Do i need to activate it?Schoening2012-04-18 17:50:01
B
40
S
11
G
4
Posts: 665
Reputation: 8,403

Post » Wed Apr 18, 2012 6:03 pm

Go for it. It'll fall back to default if it is not supported, anyway.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Wed Apr 18, 2012 6:11 pm

Alright ^^
B
40
S
11
G
4
Posts: 665
Reputation: 8,403

Post » Wed Apr 18, 2012 6:34 pm

The blog post on garbage collection was really aimed at plugin/behavior developers, as well as general Javascript programmers. From within C2, you don't really need to worry about GC at all. We've already done all the work to minimise GC.
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,228

Post » Wed Apr 18, 2012 8:36 pm

[QUOTE=Ashley] The blog post on garbage collection was really aimed at plugin/behavior developers, as well as general Javascript programmers. From within C2, you don't really need to worry about GC at all. We've already done all the work to minimise GC.[/QUOTE]

I love when other people do the work
B
40
S
11
G
4
Posts: 665
Reputation: 8,403

Next

Return to Construct 2 General

Who is online

Users browsing this forum: makarone and 3 guests