The easiest way is done the way Baxslash and Agent describe but without deleting the sprites before SYNC (Agents method). It's easier to reuse sprites rather than recreating them every loop.
1. Create the sprite
2. Hide the sprite
3. Paste the sprite
4. Write text over the pasted sprite
5. Go to step 3
Think of sprites as something that hovers over the screen. If you place a sprite it'll block the view of the screen below it. So if you write text in the same spot the sprite is you won't see it because the sprite is blocking the view. HIDE SPRITE allows you to have the sprite wherever you want it (on the screen or off) and not see it so you can view the screen under the sprite. PASTE SPRITE is like a stamp... it stamps the screen with whatever the sprite looks like. If you write text after PASTE SPRITE it'll be over the pasted sprite.
` Set sync rate and turn on syncing
sync rate 0
sync on
` Create an image and grab it
box 0,0,50,50,rgb(255,0,0),rgb(0,255,0),rgb(0,0,255),rgb(255,255,255)
get image 1,0,0,50,50,1
` Create a sprite
sprite 1,0,0,1
` Offset it so it's centered
offset sprite 1,25,25
` Hide the sprite
hide sprite 1
` Create a 3D box
make object cube 1,100
` Create a timer
tim=timer()
` Hide the mouse
hide mouse
do
` Show the sprite at the mouse coordinates
paste sprite 1,mousex(),mousey()
` Show the text
center text mousex(),mousey()-20,"Angle"
center text mousex(),mousey()+5,str$(wrapvalue(Angle))
` Check if it's time to rotate
if timer()>tim+20
` Increase the angle
inc Angle
` Rotate the cube
rotate object 1,wrapvalue(Angle),0,0
` Rotate the sprite
rotate sprite 1,wrapvalue(Angle)
` Reset timer
tim=timer()
endif
` Update the screen
sync
loop