Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Physics Sprites reporting the same by-offset coordinates regardless of what the chosen offset is (Tier 2)

Author
Message
Jerry McGuire
7
Years of Service
User Offline
Joined: 25th Mar 2017
Location:
Posted: 28th Aug 2018 18:29
Hi, I am trying to follow the movement of a sprite set to physics-dynamic. But I want to do this using the offset coordinates because I am interested in the movement of a particular "pixel" of the sprite. However, regardless of what offset I use, I always get the same by-offset coordinates.
Example in pseudocode:

create square sprite 100x100 and name it "square";
set square's offset to (x,y);
set square as dynamic physics object;
do loop {
print(square's coordinates by offset);
}

This code will always give me the default offset coordinates (the ones in the center of the sprite) regardless of my choice of "x" and "y". Am I doing something wrong or is this a bug or a limitation of the AppGameKit commands?
iMac Book Pro, MacOS 10.12.4, Xcode 9.0.1;
iPhone 6, iOS 9.35; iPhone 5s, iOS 9.35; iPad (3rd gen), iOS 9.35;

Dell Precision T7400, Windows 7 Professional 64bit, Visual Studio Community 2017;

The author of this post has marked a post as an answer.

Go to answer

Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 28th Aug 2018 19:55 Edited at: 28th Aug 2018 19:56
Ive just tried this in both Teir 1 and Teir 2 on windows

They both do the same thing and they both correctly give back the x and y position of the offset.
GetSpriteXByOffset(id)
GetSpriteYByOffset(id)

So if I move the offset to the bottom right of your square 100,100 then the position returned starts at 100,100 then slowly accellerates down the screen due to gravity as we would expect.

Are you sure you are using the right commands? Do you have some sample code as Id guess that your doing something wrong.
Jerry McGuire
7
Years of Service
User Offline
Joined: 25th Mar 2017
Location:
Posted: 29th Aug 2018 00:16 Edited at: 29th Aug 2018 00:17
You're right Bengismo.
I think I figured out what my problem is: the shapes of the physical sprite move with the offset as well. So if I want to track this point by setting the corresponding offset, that shifts all the assigned shapes, and it all gets messed up. Mmmmhhh. I'll have to compute the new shapes (positions) taking the offset into account. That's it I think. I'll try and see if it works.
iMac Book Pro, MacOS 10.12.4, Xcode 9.0.1;
iPhone 6, iOS 9.35; iPhone 5s, iOS 9.35; iPad (3rd gen), iOS 9.35;

Dell Precision T7400, Windows 7 Professional 64bit, Visual Studio Community 2017;
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 29th Aug 2018 18:26
use
SetPhysicsDebugOn()
when first setting up your project and you will see the physics shapes on screen.
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
Jerry McGuire
7
Years of Service
User Offline
Joined: 25th Mar 2017
Location:
Posted: 30th Aug 2018 16:59
This post has been marked by the post author as the answer.
Thank you Bengismo and smallg. It helped me have a "sanity check" and a way to figure out how to solve my problem!
iMac Book Pro, MacOS 10.12.4, Xcode 9.0.1;
iPhone 6, iOS 9.35; iPhone 5s, iOS 9.35; iPad (3rd gen), iOS 9.35;

Dell Precision T7400, Windows 7 Professional 64bit, Visual Studio Community 2017;

Login to post a reply

Server time is: 2024-11-23 14:48:16
Your offset time is: 2024-11-23 14:48:16