Position of created object is 0, 0 although it should not be

Get help using Construct 2

Post » Wed Oct 25, 2017 9:22 pm

Hi,

I have this case which is driving me crazy:

Code: Select all
myEnemy | On created     |     System | Create object    myFont at (myEnemy.X, myEnemy.Y)


I create my "myEnemy" at a valid Position != 0 (let´s say at 25, 130) but... when "myFont" is created like shown above at myEnemy.X and myEnemy.Y it is created at 0, 0...
I would expect the X and Y to be correct even in the "On created" event?

Please... :?
B
5
S
1
Posts: 23
Reputation: 486

Post » Wed Oct 25, 2017 9:35 pm

The on created trigger is probably running before your myEnemy sprite has any properties.

Try a different method, such as using a container, adding the create myFont action to the event that created myEnemy in the first place. The "wait 0" trick might work here too, if you put that above the spawn action.
Mistakes were made.
B
57
S
28
G
115
Posts: 1,712
Reputation: 65,172

Post » Thu Oct 26, 2017 9:36 am

Ah, you saved me! You're right, the position is not yet set in the onCreate event. So you can imagine the event as a kind of constructor but without parameters. I am creating my "myFont" Object at a later stage now.
B
5
S
1
Posts: 23
Reputation: 486


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 24 guests