Hello everyone, how are ya all doing ?
I would like to show you two of my functions and how to use them.
The first deletes all the sprites currently on the screen:
FUNCTION delete_all_sprites(x,total_sprites)
FOR x = 1 TO total_sprites
IF SPRITE EXIST(x) THEN DELETE SPRITE x
NEXT x
ENDFUNCTION
To use this function place the "delete_all_sprites()" before the loop.
delete_all_sprites(x,5)
This then will remove the total sprites on the screen.
The next function will check for a left mouse click on a sprite on the screen. It will then play a sound when the sprite has been clicked.
FUNCTION mouse_over(no_sprite,state)
state=0
IF SPRITE EXIST(no_sprite)
IF MOUSEX()>SPRITE X(no_sprite) AND MOUSEX()<(sprite x(no_sprite)+sprite width(no_sprite))
IF MOUSEY()>SPRITE Y(no_sprite) AND MOUSEY()<(sprite y(no_sprite)+sprite height(no_sprite))
REM Check for left mouse click
IF MOUSECLICK()=1
PLAY SOUND 1
sleep 100
state=1
ELSE
state=0
ENDIF
ENDIF
ENDIF
ENDIF
Rem Pass out the value for the state
ENDFUNCTION state
To use this function place "mouse_over()" within your loop.
mouse_over(2,1)
This will check for the mouse over the sprite and a left mouseclick of the sprite number "2".
I hope you find these functions useful and if you use them please give me credit where appropiate to James Crockford.
Comments welcome.