Get Sprite Position

Get help using Construct 2

Post » Thu Jul 05, 2012 6:01 am

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?

Thanks.
B
2
Posts: 2
Reputation: 354

Post » Thu Jul 05, 2012 7:49 am

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Thu Jul 05, 2012 6:23 pm

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.


http://dl.dropbox.com/u/49160279/game.capx


Thanks
B
2
Posts: 2
Reputation: 354

Post » Thu Jul 05, 2012 7:23 pm

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.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346


Return to How do I....?

Who is online

Users browsing this forum: Allen T, juh9870, Radulepy and 13 guests