Posted: 9th Oct 2003 21:07
I love the Pick Object Command but I needed Pick Sprite so here it is

+ Code Snippet
Function Pick_Sprite(Target)
   rem change 999 to any number you wish
   rem move the next line outside of main loop should only be called once
  get image 999,1,1,2,2
  sprite 999,mousex(),Mousey(),999
  hit = sprite collision(999,Target)
  rem the following is only for testing
  set cursor mousex()-200,Mousey()
  print "Hit Sprite # : ",hit
EndFunction hit


If you use a specific sprite number as Target it will return "1" if cursor is over Target sprite
Pick_Sprite(Target)

If you use Pick_Sprite(0) it will return the number of the lowest sprite only (if multiple sprites overlap)
Posted: 13th Oct 2003 1:34
You could achieve the same affect by checking if the mouse is in the borders of the sprite. To find the borders of the sprite it would just be like a collision box.

RPGamer
Posted: 13th Oct 2003 6:58
RPGamer
If you had a program with 100 Sprites That would require you to loop through all sprites, check thier shape and test it against the cursor position. This function is far cleaner
Posted: 17th Oct 2003 9:57
so basicly, this will see if two objects are overlapping?
Posted: 18th Oct 2003 18:13
Not "Objects" "sprites"
The existing command PICK OBJECT is for that. Bascially the idea is to see if mouse is over a sprite by comparing a 1 pixel sprite positioned at MouseX(),MouseY(). I use it to good effect in the "Sunk / Raised Command Buttons" snippit in this forum