How do I obtain current x and x coordinates of an object?

0 favourites
  • 7 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • Hi there, still a newbie but loving C3!

    I have several sprites that are arranged in random order on the On Load of a layout.

    However, they are draggable and when you drag to an incorrect location, they need to return to the original random spot they start at.

    So every time you load the screen they will have a different start position which needs to be updated...? Hope that makes sense, I basically just need to save an XY of an object for later reference maybe....?

    Thanks for looking and any help is much appreciated....

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Make two instance variables within the object, for example startX and startY. On start of layout, for each object, set startX and startY to self.x and self.y.

  • Oosyrag,

    Thasnk for the information and clues...I have done that and it makes sense.

    Now How can I use the StartX and StartY instance variables?

    I need to access them in the Else statement and wondering if I do

    Set Position or Set X and Set Y because I cannot type in the Instance Variables into those choices?

    Very close to what I need just missing the mechanics...? :-)

  • You would use them in an expression, object.startX and object.startY.

    Have you done the beginner's tutorial? You should probably do that before anything else.

  • I am very lame, but yes I have completed tutorial and many C3 projects, but my script aspect of C3 is horrible.

    Thanks for the hints, as I now have my "Engine" working using your guidance.

    Else statement now has Set Position to(self.StartX, self.StartY)

    I tried object.startY.....but Object keeps filling in with objectcount...?

    Thanks again, and I will always pass it forward if given the opportunity...

    Best regards,

  • Object would be the name of your sprite object. I would have no way of knowing what you called it. Self also works.

  • OMG!!!! Yes my bad thanks again for your help.....

    Totally appreciation and thanks :)

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