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
6
S
1
Posts: 25
Reputation: 517

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
62
S
30
G
134
Posts: 1,975
Reputation: 75,477

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
6
S
1
Posts: 25
Reputation: 517


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest