edit time counting instances?

For developers using the Construct 2 Javascript SDK

Post » Sun Aug 03, 2014 6:22 pm

Is there a way in the edit time to log when an instance was destroyed?

(On destroyed function)
instcount = instcount - 1;


What I want is a running total of instances during runtime.
www.h1k3.tech

We are here for you!
B
87
S
23
G
16
Posts: 715
Reputation: 16,835

Post » Sun Aug 03, 2014 7:34 pm

@lanceal

Sprites have a Count expression (e.g. Sprite.Count) that you can use to keep a running total of instances during runtime.

Here's a simple example:
SpriteCount.capx
You do not have the required permissions to view the files attached to this post.
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 467
Reputation: 6,864

Post » Mon Aug 04, 2014 12:56 pm

I do appreciate that, but that doesn't really help. I'm looking at the actual javascript, not the application. Thank you though. :)
www.h1k3.tech

We are here for you!
B
87
S
23
G
16
Posts: 715
Reputation: 16,835

Post » Mon Aug 04, 2014 12:58 pm

Sorry, this is not supported. What do you need it for?
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,361

Post » Mon Aug 04, 2014 2:18 pm

@Ashley

I'm trying to get a running total of instances in the app. I can add to the number every time one is created but the minute an instance is removed, everything is wrong. :( any ideas?
www.h1k3.tech

We are here for you!
B
87
S
23
G
16
Posts: 715
Reputation: 16,835

Post » Mon Aug 04, 2014 3:03 pm

If you explain why you need this, perhaps there is another solution.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,361

Post » Mon Aug 04, 2014 4:38 pm

@Ashley

It's rather complicated, or maybe it just seems that way. I'm writing a plugin that uses instances to visualize screen objects(like the button div)

However it uses technology called parse so just creating the div isn't enough. Once all the divs have been created I need to run an action called parse on the divs. But I only want to do it once. So I want to keep a running total on the number of instances. That way during runtime I can have a variable that increases with every div. Once the variable reaches the number of instances I know that it is safe to run the parse function.
www.h1k3.tech

We are here for you!
B
87
S
23
G
16
Posts: 715
Reputation: 16,835

Post » Tue Aug 05, 2014 9:00 am

@lanceal - woops, my bad, didn't notice this was in the Javascript SDK sub-forum :P
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 467
Reputation: 6,864


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest