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 / Physics collision issue (Lazarus)

Author
Message
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 25th Nov 2012 18:58
Hi all,

I am having a little trouble with physic sprite collisions. Just wrote a test brick breaker level. I use getfirstcontact...to detect an initial collision and this is detected. I then loop through the brick sprites to see which was hit. After this I set the sprite to not visible and switch of its physics.enabled=false.

This works however, the brick is switched off at the point of collision but sometimes before the ball has bounced off! So the ball hits a block, the block is 'deleted' and the ball continues on its original journey?

How can I ensure the ball has 'reacted' or bounced of the brick before I remove the brick?


Thanks all?

Constantly seeking!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Nov 2012 19:31
Contacts are not always collisions, you need to loop through the contacts, then check for an actual collision before switching the brick off. Or you could check whether your ball has changed direction...


this.mess = abs(sin(times#))
Auger
12
Years of Service
User Offline
Joined: 21st Aug 2011
Location: Out There
Posted: 25th Nov 2012 19:41
Quick question do you have SetSpriteShape( iSpriteIndex, shape ) set to a circle for your ball? If so then maybe I'd set a timer to update all your blocks destroyed and then delay their deleting by a small time.

Auger
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 25th Nov 2012 21:02
Auger, that's the exact workaround I have implemented. And it works but I hoped it did not have to be a 'workaround'!

Baxslash...thanks that makes perfect sense on both counts. I will try both to see which works fluently and most accurately!


Many thanks guys....much appreciated as usual!

Constantly seeking!

Login to post a reply

Server time is: 2024-05-02 08:55:14
Your offset time is: 2024-05-02 08:55:14