As I recently had to customise the mouse cursor for my new prototype, I thought I'd write a tutorial on the subject. Here it is:
Custom Cursors in Love2D
Custom Mouse Cursors (Tutorial)
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Custom Mouse Cursors (Tutorial)
I would add a sentence explaining that it's better to draw the image using a '0, 0' (top-left) origin if you want a traditional mouse pointer and not a crosshair.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Re: Custom Mouse Cursors (Tutorial)
I'm disappointed! You even't implemented normal/clicking states in your tutorial? That's bellow your usual quality! ;D
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Custom Mouse Cursors (Tutorial)
Good point.Lafolie wrote:I would add a sentence explaining that it's better to draw the image using a '0, 0' (top-left) origin if you want a traditional mouse pointer and not a crosshair.
Huh? I've no idea what you mean. If you've talking about keeping track of clicking and the like, that's going beyond the intended scope of this tutorial.coffee wrote:I'm disappointed! You even't implemented normal/clicking states in your tutorial? That's bellow your usual quality! ;D
Re: Custom Mouse Cursors (Tutorial)
Since your tutorial was about teach how to use custom mouse cursors, I would think that fits in your intended scope of tutorial also cover custom "mouse states". As you guess something (quickly imagined) like this:BlackBulletIV wrote:Huh? I've no idea what you mean. If you've talking about keeping track of clicking and the like, that's going beyond the intended scope of this tutorial.
Code: Select all
function love.load()
cursor_off = love.graphics.newImage("crosshair_off.png")
cursor_on = love.graphics.newImage("crosshair_on.png")
cursor = cursor_off
love.mouse.setVisible(false)
love.mouse.setGrab(true)
end
function love.mousepressed(x, y, button)
if button == 'l' then cursor = cursor_on end
end
function love.mousereleased(x, y, button)
if button == 'l' then cursor = cursor_off end
end
-- or other better way of swap cursor of course
function love.draw()
love.graphics.draw(cursor, love.mouse.getX() - cursor:getWidth() / 2, love.mouse.getY() - cursor:getHeight() / 2)
end
- josefnpat
- Inner party member
- Posts: 955
- Joined: Wed Oct 05, 2011 1:36 am
- Location: your basement
- Contact:
Re: Custom Mouse Cursors (Tutorial)
It's also worth taking note that it may lag on some systems, and you want to offer an option to disable vsync!
Missing Sentinel Software | Twitter
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Custom Mouse Cursors (Tutorial)
@coffee: Ah I see. I might just add that.
@josefnpat: Another good point. Though with all things I should add, I'll have to structure the tutorial a bit different I think.
@josefnpat: Another good point. Though with all things I should add, I'll have to structure the tutorial a bit different I think.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Custom Mouse Cursors (Tutorial)
For some strange reason, the wiki page I created for this tutorial isn't appearing in the tutorials category. And yeah, I've purged the tutorials page multiple times. Anyone know what's going on?
Who is online
Users browsing this forum: No registered users and 75 guests