SpawnObject() vs. System.Create() in a Python script?

For questions about using Classic.

Post » Sat Aug 28, 2010 7:26 am

Is there any difference between these two functions? I can't even get SpawnObject to work at all in a script, though it works fine as an action in the event sheet. Am I correct that System.Create will produce instances of the object in question, still indexable as normal? Well, they are indexable, I just checked. I guess I wanted to make sure that if I create 400 copies of a sprite using System.Create, I am not wasting resources actually making new objects, they are for real just instances.

Thanks!
B
1
G
2
Posts: 4
Reputation: 633

Post » Sun Aug 29, 2010 6:05 am

Welcome to the forms. Both those functions are just wrappings of their event counterparts, which create new instances of the specified object. Are you getting the error "NameError: name 'SpawnObject' is not defined"? If so, then you're calling SpawnObject wrong.

Examples of usage.
[code:9dbub4pk]System.Create('Sprite2', 1, Sprite.X, Sprite.Y)[/code:9dbub4pk]
will do the same thing as
[code:9dbub4pk]Sprite.SpawnObject('Sprite2', 1, 0)[/code:9dbub4pk]

-cheers
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Sun Aug 29, 2010 11:00 pm

Hey, thanks for the info and the welcome. It turns out I was failing to put the sprite name in single quotes when calling SpawnObject - an error I should have spotted since I was using quotes correctly with System.Create! But it's good to know that they are equivalent, that's what I was looking for, thanks!
B
1
G
2
Posts: 4
Reputation: 633


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest