Using the asteroid project as my template, I tried to make a sprite move with the mouse. Not working.
Here's what I've got:
Dim CursorSprite
Dim MouseX, MouseY
Sub FindCursor()
Dim I
With ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer
For I = 0 To .SpriteCount - 1
If .Sprite(I).rDef.Name = "Cursor" Then
Set CursorSprite = .Sprite(I)
Exit Sub
End If
Next
End With
End Sub
Sub Display_MouseMove(Button, Shift, X, Y)
If IsEmpty(CursorSprite) Then
FindCursor()
Exit Sub
End If
With ProjectObj.GamePlayer
CursorSprite.X = X + .MapScrollX - .rMap.ViewLeft
CursorSprite.Y = Y + .MapScrollY - .rMap.ViewTop
End With
MouseX = X
MouseY = Y
End Sub
Sub Player_OnAfterMoveSprites()
If IsEmpty(CursorSprite) Then
FindCursor()
Exit Sub
End If
With ProjectObj.GamePlayer
CursorSprite.X = MouseX + .MapScrollX - .rMap.ViewLeft
CursorSprite.Y = MouseY + .MapScrollY - .rMap.ViewTop
End With
End Sub
HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16
From what I can tell, CursorSprite is being set to the right sprite; it moves around a bit when the map scrolls, just like if you don't move the mouse in the asteroid project. When I run my project, it acts as though the mouse isn't moving. That is, it just hangs out in the upper-left corner of the screen. My guess is that I did something wrong in the Sub Display_MouseMove part.
So... any suggestions?