Jump to content

How to change the mouse icon


Thirsty Panther
 Share

Recommended Posts

I'm working on a version of Operation Wolf www.arcade-museum.com/game_detail.php?game_id=8927 for the Halloween Games tournament.

In this the players character stays still and moves the mouse to target enemies. For this I need to change the default mouse pointer to a crosshair.

My current idea is to hide the default mouse pointer with window:hideMouse and to draw a crosshair image in its place. My problem is to getting the mouse co-ordinates and applying them to the crosshair image.

Window:GetMousePosition gives a vec3 but I'm clueless on how to apply these to the crosshair image.

Any help would be appreciated.

 

 

Link to comment
Share on other sites

Window:GetMousePosition()

This function gets the mouse position. The X and Y components of the returned values are the screen coordinates, and the Z component is the mouse wheel position.

 

example:

window = Window:Create("crosshair",0,0,800,600,window.Titlebar+window.Center)

context = Context:Create(window)

world = World:Create()

camera = Camera:Create()

camera:Move(0,0,-3)

light = DirectionalLight:Create()

light:SetRotation(35,35,0)

 

model = Model:Box()

model:SetColor(1,.5,0,1)

 

crosshair = Texture:Load("Materials/Crosshair/crosshair.tex")

ch_width = crosshair:GetWidth()

ch_height = crosshair:GetHeight()

 

--window:HideMouse()

 

while window:KeyDown(Key.Escape)==false do

model:Turn(0,Time:GetSpeed(),0)

Time:Update()

world:Update()

world:Render()

 

m_pos = window:GetMousePosition()

 

context:SetBlendMode(Blend.Alpha)

context:DrawImage(crosshair, m_pos.x - (ch_width/2), m_pos.y - (ch_height/2))

context:DrawText("Mouse position: "..m_pos.x..", "..m_pos.y, 2, 2)

context:SetBlendMode(Blend.Solid)

 

context:Sync()

end

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...