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 / SetSpriteFlip() vs Physics

Author
Message
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 31st Jan 2019 18:33 Edited at: 31st Jan 2019 19:09
flipping a sprite horizontally is causing the collision circle to flip vertically (flipping vertically works fine):




i can call SetSpriteShapeCircle(This,0,-12,12) each time to reset it but i believe it to be a bug, otherwise.

meanwhile, while the docs state that cloned sprites do not copy physics, it appears they do?
Quote: "Any physics values or shapes assigned to the sprite will not be copied. The new sprite will not be setup for physics. "

i can't be bothered to test this because it doesn't pertain to my project but the collision circle is there.

Here's the actual project: i don't think there are any misses recorded but you can see the collision circle flipping vertically and i've seen "hits" miss more than once during testing.

also note the physics lag ~ 0:26 which was introduced when i added a flip Timer()...

add: GetSpriteFlippedH needs to be added to [agkcode]

Attachments

Login to view attachments
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 31st Jan 2019 19:11
getting the same behaviour too, i'd say it's a bug as the docs say flipping is supposed to be only a visual change.
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 31st Jan 2019 19:30 Edited at: 31st Jan 2019 19:31
Definitely a bug and it actually affects both horizontal and vertical flipping when specifically using circle shapes.

In the AppGameKit source code file csprite.cpp on line 1420

((b2CircleShape*)pShape)->m_p.x = -((b2CircleShape*)pShape)->m_p.x;
((b2CircleShape*)pShape)->m_p.y = -((b2CircleShape*)pShape)->m_p.y;

should be:

if ( (horz ^ currHorz) != 0 ) ((b2CircleShape*)pShape)->m_p.x = -((b2CircleShape*)pShape)->m_p.x;
if ( (vert ^ currVert) != 0 ) ((b2CircleShape*)pShape)->m_p.y = -((b2CircleShape*)pShape)->m_p.y;

Hopefully paul will update for the next release...


Also, on line 285 of the same file...when a sprite is cloned the collision Shapes ARE copied over...the documentation isnt exactly clear about that. Ive not checked if the rest of the physics properties are copied over though)
puzzler2018
User Banned
Posted: 31st Jan 2019 19:36
Awesome problem solving here

Good one..
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 31st Jan 2019 20:00 Edited at: 31st Jan 2019 20:05
thanks for confirming, guys. i'll post a bug report if paul doesn't see this soon.

otherwise, what about the physics lag vs timer()? it's definitely not the vid capture interfering. i thought i saw a thread about similar recently but review of the past month's threads proved fruitless.

add: hmmm. just remembered that i already had a timer() in there before the flip code was added but had no issues. maybe it's multiple calls within the same loop? i'll remove and find out

Login to post a reply

Server time is: 2024-11-05 18:39:57
Your offset time is: 2024-11-05 18:39:57