Spawn Object By Name

Get help using Construct 2

Post » Fri Dec 13, 2013 4:27 pm

Hi everyone.

As you could guess I am trying to implement an Action that I may use to Spawn an instance of a given type by its name. I am not sure if this kind of action would be a bad practice but if not (or even if is I would like to know if there is a way I can create an instance through its name just our of curiosity) I need to know how could I get the type of a given Object in the runtime.js. Thank you before hand.Jhonathan Ibanez2013-12-13 16:33:43
B
10
S
3
Posts: 75
Reputation: 864

Post » Fri Dec 13, 2013 4:32 pm

If you mean by a string containing the name, you should take a look at a third party plugin called nickname.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Dec 13, 2013 4:39 pm

Yeah I mean something like...

function SpawnByName(name,layer,imgpt){

var obj = name.type; //I know there is not property that would allow me to //do this but I do know there is a runtime.type_by_index property that I //can use and that there is a certain property type.index that would come //in handy too for this
var ins = this.runtime.createInstance(obj, layer, this.getImagePoint(imgpt, true), this.getImagePoint(imgpt, false));

/*
...
...
..
*/

}Jhonathan Ibanez2013-12-13 16:42:12
B
10
S
3
Posts: 75
Reputation: 864

Post » Fri Dec 13, 2013 4:42 pm

That all looks like Chinese to me so it's probably some script language..

I'm glad C2 uses event and not script.. :)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Dec 13, 2013 4:46 pm

heheheh xD!!. Man thank you, that plugin is exactly what I was looking for :)
B
10
S
3
Posts: 75
Reputation: 864


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests