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
42
S
19
G
12
Posts: 723
Reputation: 13,911

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
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

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
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Dec 08, 2011 7:45 am

Thanks Guys! That helped to solve the task!
B
42
S
19
G
12
Posts: 723
Reputation: 13,911


Return to How do I....?

Who is online

Users browsing this forum: Kagubro, MisterAqua and 22 guests