how to destroy all instances of CRunObjType* pMyType

Forum for plugin, effect and behavior programmers. Please use the Help & Support forum for help using Construct.

Post » Fri Jun 19, 2009 9:10 pm

given CRunObjType* pMyType,
how can I destroy all instances of pMyType?
assuming that no picking of any kind has been done
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Fri Jun 19, 2009 9:56 pm

Call VRuntime::GetTypeInstances to get a list of the instances in that type, then call VRuntime::DestroyObject on each of them.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,554

Post » Fri Jun 19, 2009 11:28 pm

I know you don't have time to teach me c++, ash
but honestly, I just need to get around this so I can get the other bitmap text stuff done on my weekend
I'll be learning about vectors on a later date,
but I just need to destroy all instances, so if anyone, ashley or otherwise
wants to help me out with

[code:27394pvf]GetTypeInstances(CRunObjType* pType, CRunObject**& instancesList, int& count)[/code:27394pvf]
I'm pretty much lost on the whole thing
I get that I need to pass it a pointer to a pointer to a CRunObject, but I'm really just shooting in the dark reading through the sprite plugin, and trying to speed learn vectors

given pType, and an int named count
how do I set up a loop iterating through all the instances?
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Fri Jun 19, 2009 11:38 pm

It has nothing to do with vectors :P

[code:f76xay8n]CRunObject** instances;
int count;
pRuntime->GetTypeInstances(pType, instances, count);

if (instances != NULL) {
CRunObject** i = instances;
CRunObject** end = instances + count;

for ( ; i != end; ++i)
pRuntime->DestroyObject(*i);
}[/code:f76xay8n]
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,554

Post » Fri Jun 19, 2009 11:40 pm

thanks ash, you rock

I was totally lost in the sprite collision test vector iteration Sol modification code

now I can finish the rest of this plugin, and I'll have time to read my c++ pdfs

:mrgreen:
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461


Return to Construct engineering

Who is online

Users browsing this forum: No registered users and 0 guests