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.

Newcomers AppGameKit Corner / Collision and transparency

Author
Message
okee
10
Years of Service
User Offline
Joined: 1st May 2014
Location: Ireland
Posted: 28th Mar 2017 21:51
What's the best method for accurate collision detection ?
Just testing with a 1x1 sprite hidden under the mouse sprite to detect
collision against shapes

with a circle sprite
SetSpriteShape( sprBall, 1 ) works very accurately

but with something like a star I can't get accurate collision with any of the settings
once the pixel goes into the transparent area it detects a collision
SetSpriteShape( sprStar, 2 )

Also is it better to cut out any transparent area around an image when saving in an image editor
so if a sprite is 48 x 38 in size, save it as a 48 x 38 image rather than 64 x 64 ?


Increase
7
Years of Service
User Offline
Joined: 21st Feb 2017
Location:
Posted: 28th Mar 2017 23:43 Edited at: 28th Mar 2017 23:44
I guess it's best to set the collision polygon yourself with SetSpriteShapePolygon( iSpriteIndex, numPoints, index, x, y ) for more complex images.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Mar 2017 00:11
You could use this handy utility to create the shape
https://forum.thegamecreators.com/thread/212975#msg2544432
damothegreat
User Banned
Posted: 1st Apr 2017 21:59 Edited at: 1st Apr 2017 22:04
I'm implementing a per pixel piece of code and entering into the AppGameKit Challenge area

ok we have tools scattered about all over the place for detection.

I want my own routines and can share them in your own projects

Watch this space
Vladimuffin
7
Years of Service
User Offline
Joined: 27th Nov 2016
Location:
Posted: 27th Apr 2017 22:59
Hello Guys,
I am still learning with AppGameKit but have some fun projects underway. In one app I was hoping to create a single PNG (with transparencies) to use as the walls for a top down game (similar to the walls of a pac-man-like game). Is there any way to create a single sprite that has collision wherever there is no transparency? Or do I just need to make every wall an individual sprite? I appreciate any assistance offered!

Wilf
Valued Member
18
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 1st May 2017 10:32
Is it important that the physics are derived from a single .png? I think you're better off using Tiled and SetSpriteShapePolygon() to process Object shapes. Phaelex just updated his importer too. The one I use is based off this thread.

Load in a tmx map, assign a sprite per Object and modify that sprites polygons with something like this (using commands from the old version)
Just remember to keep your objects under 12 points, convex, and build them with the points going in a clockwise direction.

Login to post a reply

Server time is: 2024-11-22 03:47:01
Your offset time is: 2024-11-22 03:47:01