func_graphics_max2d_collideimage.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. .. _func_graphics_max2d_collideimage:
  2. ============
  3. CollideImage
  4. ============
  5. CollideImage -
  6. Description
  7. ===========
  8. .. code-block:: blitzmax
  9. CollideImage:Object[](image:TImage,x,y,frame,collidemask%,writemask%,id:Object=Null)
  10. Pixel accurate collision testing between transformed Images.
  11. The @collidemask specifies any layers to test for collision with.
  12. The @writemask specifies which if any collision layers the @image is added to in it's currently transformed state.
  13. The id specifies an object to be returned to future #CollideImage calls when collisions occur.
  14. Parameters
  15. ==========
  16. Return Values
  17. =============
  18. Nothing.
  19. Examples
  20. ========
  21. .. code-block:: blitzmax
  22. Strict
  23. Local rot,x,y
  24. Graphics 640,480
  25. AutoMidHandle True 'image will rotate around it's center
  26. Local image:TImage=LoadImage("bullet.png")
  27. While Not KeyHit(KEY_ESCAPE)
  28. Cls
  29. ResetCollisions
  30. ' draw the first image at 5 times the size and on an arbitrary angle
  31. SetScale 5,5
  32. SetRotation 125
  33. DrawImage image,200,200
  34. ' add the first image to the first collision layer at same postion, rotation
  35. ' and scale as it has just been drawn
  36. CollideImage image,200,200,0,0,1
  37. ' move the other image relative to the mouse and rotate it continuously
  38. x=MouseX()
  39. y=MouseY()-20
  40. rot:+1
  41. SetRotation rot
  42. DrawImage image,x,y
  43. ' test the image at it's current rotation, scale and position with images
  44. ' that have been added to the first collision layer
  45. If CollideImage(image,x,y,0,1,0)
  46. ' reset scale and rotation states so our text is drawn correctly
  47. SetScale 1,1
  48. SetRotation 0
  49. DrawText "COLLISION!",20,20
  50. EndIf
  51. Flip
  52. Wend
  53. See Also
  54. ========