Get Sprite Position

0 favourites
  • 4 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • Hello, by this moment I'm creating a space game, the basic idea is compute the gravity value acording to X and Y positions in order to atract the space ship to planets, i tried:

    set Radio to distance(0,0,sprite.X,spriteY)

    set text to " " & Radio

    but in several times the text box is void, could be a bad computation or there is another way to do this?


  • I guess it's an error into the line you copied into this post, but it should be sprite.Y

    Also, the 0,0 coordinate you give first is the top left corner of the layout. Not sure why you want to measure the distance between this point of the screen and a Sprite that possibly is your ship.

    Perhaps instead of the 0's you should put the planet coordinates.

    Try posting your capx, or a capx that reproduce the issue, detailing more precisely what you'd expect.

    Check also the how do I FAQ there is at least one element listed treating about gravitation, possibly it could help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes, it was my mistake, into the code is sprite.Y , the point 0,0 was the easier point for verify that the code is working, but you're right the correct point is the center of the planet.

    I'm posting the capx, the idea in the textbox will appear X,Y coordinates and calculated Radio, also i have a question about how modify the gravity direction, how modify with a angle.


  • gravityShip.capx

    The radius was properly calculated, just not properly displayed, your text object was too short, and it's also better to round the values.

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