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

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi,

    I have this case which is driving me crazy:

    myEnemy | On created     |     System | Create object    myFont at (myEnemy.X, myEnemy.Y)
    [/code:39kng7lx]
    
    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...
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)