|
CompareSpritePixels | |
CollisionState = CompareSpritePixels(SpriteIndex1, SpriteIndex2, Accuracy#) | |
Parameters: SpriteIndex1 = The Source Sprite to check for collision against SpriteIndex2 = The Dest Sprite to check for collision against Accuracy# = The level of accuracy that should be used. |
|
Returns: CollisionState = The result of the collision query (0= No collision ,1 = Collision) |
|
The CompareSpritePixels function detects if a pixel level collision occurs between a pair of sprites. The Accuracy parameter allows the user to fine tune the quality of the pixel level collisions. Generally speaking, the lower the quality the faster the comparison will be. On the flip side, the higher the quality the more accurate, but slower the comparison. It's up to you to pick the accuracy level that is appropriate for your images and the performance requirements of your game. Example Accuracy Values 0.25 = Reduce collision accuracy to 25% 0.50 = Reduce collision accuracy to 50% 0.75 = Reduce collision accuracy to 75% 1.00 = Set collision accuracy to 100% 2.00 = Set collision accuracy to 200% FACTS: * Sprite Images should be prepared as FX images for best speed! See SpriteImage, PrepareFXImage, LoadFXImage etc etc * Pixels level collisions ignore the sprites transparent colour. Mini Tutorial: This example creates a random image, creates 10 randomly positioned sprites on the screen using this image. The main loop rotates the sprites while scans them for collisions using CompareSpritePixels
|
|
|||||||||||||||||||||||||||||||||||||||
(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com |