Code archives/Miscellaneous/Sprite Candy Cursor

This code has been declared by its author to be Public Domain code.

Download source code

Sprite Candy Cursor by RifRaf2006
Ive had SC now for about 5 minutes . Did not see right away a quick and easy function for a mouse cursor in fullscreen mode, using the gui addon for sc. So i made this real quick. Hopefully I dont see a built in function for this in the next 10 minutes :)

I didnt see any user forums for this library , or I would have posted this there.

Just call Gui_LoadCursor(Filename$,gamecamera,texture flag)
then Gui_UpdateCursor() Once per game loop
;---------------------------------------------------
;Cursor function added by rifraf ( jeff frazier )
;---------------------------------------------------
Function Gui_LoadCursor(CurFile$,Cam,flag=4)
    If CursorHud<>0 Then 
      HUD_FreeImageResources(Cursorimage)
      HUD_ClearLayer(CursorLayer)
      HUD_RemoveLayer(CursorLayer)
      HUD_Remove(CursorHud)
      cursorimage%=0 
      CursorHud%=0  
    EndIf
    If FileType(curfile$)<>1 Then RuntimeError "Gui_LoadCursor : File "+curfile$+" not found."
    TempImage=LoadImage(curfile$)
    CursorWidth=ImageWidth(Tempimage)-ImageWidth(Tempimage)/2
    CursorHeight=ImageHeight(Tempimage)-ImageHeight(Tempimage)/2
    FreeImage tempimage
	CursorHud%       = HUD_Create (Cam)
	CursorResource%  = HUD_LoadImageResource (curfile$,flag)
	CursorLayer%     = HUD_CreateLayer(cursorhud,cursorresource)
	CursorImage%     = HUD_CreateImage (CursorLayer, 0,0)
    HUD_SetObjectOrder (cursorimage, 2500)
    HUD_SetObjectOrigin (cursorimage, -1,-1)

End Function 
;---------------------------------------------------
;Cursor function added by rifraf ( jeff frazier )
;---------------------------------------------------
Function Gui_UpdateCursor()
    If CursorImage=0 Then RuntimeError "Gui_UpdateCursor : Null Cursor Image"
	HUD_PositionObject Cursorimage,MouseX(),MouseY()
End Function

Comments

Boiled Sweets2006
whats wrong with...

ResourceName% = HUD_LoadImageResource (Pak("hud_gfx.png"), 4, 0,0,0 )
gfx_layer%  = HUD_CreateLayer(g_menu_hud, ResourceName, 500)
h_pointer  = HUD_CreateImage(gfx_layer, 0,0, 2,2, 24,33, "CENTER","CENTER")
HUD_SetObjectOrigin (h_pointer, -1, -1 ) 
HUD_SetObjectOrder (h_pointer, 550)
HUD_SetObjectShadow (h_pointer, 1, 3)

HUD_PositionObject(h_pointer, MouseX(), MouseY())



RifRaf2006
Nothing wrong with it, it lacks the benefits I wanted from the functions I created above.


Code Archives Forum