Event "On Spawn"?

Get help using Construct 2

Post » Wed Dec 07, 2011 5:25 pm

Is there an event "On Spawn" called by the object whe it gets initialized?
B
44
S
23
G
13
Posts: 723
Reputation: 14,895

Post » Wed Dec 07, 2011 8:52 pm

Not really.
In fact, if you want to act on objects that you already placed in your layout in edittime, you do it through through "Start of layout", making subevents for your picking needs.
Else, when you are spawning your object in your code, that is the moment to initialize it. (right after the "create object" action, if you apply code to the object type that just was spawned, only this very object is picked).
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
279
S
104
G
86
Posts: 7,313
Reputation: 84,331

Post » Wed Dec 07, 2011 10:49 pm

Sometimes I indeed need to apply stuff to a newly created sprite.
Just today I did something like that :

Add a boolean onCreate with default value true

[code]Mouse: On Left Click
    -> Create Sprite on layer 0 at 0,0
Whatever condition you need to check
Sprite: Is onCreate
    -> Sprite: Do stuff
    -> Sprite: set onCreate to false[/code]

Yann2011-12-07 22:50:32
B
64
S
22
G
14
Posts: 1,482
Reputation: 16,457

Post » Thu Dec 08, 2011 7:45 am

Thanks Guys! That helped to solve the task!
B
44
S
23
G
13
Posts: 723
Reputation: 14,895


Return to How do I....?

Who is online

Users browsing this forum: giorgio1982 and 5 guests