Difference between revisions of "love.mouse.newCursor"

m
(Removed system cursor variant)
Line 1: Line 1:
 
{{newin|[[0.9.0]]|090|type=function}}
 
{{newin|[[0.9.0]]|090|type=function}}
Creates a new hardware [[Cursor]] object.
+
Creates a new hardware [[Cursor]] object from an image file or [[ImageData]].
  
 
Hardware cursors are framerate-independent and work the same way as normal operating system cursors. Unlike drawing an image at the mouse's current coordinates, hardware cursors never have visible lag between when the mouse is moved and when the cursor position updates, even at low framerates.
 
Hardware cursors are framerate-independent and work the same way as normal operating system cursors. Unlike drawing an image at the mouse's current coordinates, hardware cursors never have visible lag between when the mouse is moved and when the cursor position updates, even at low framerates.
Line 11: Line 11:
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|ImageData|imageData| The ImageData to use as a custom image for the new Cursor.}}
+
{{param|ImageData|imageData|The ImageData to use for the new Cursor.}}
{{param|number|hotx (0)| The x-coordinate in the ImageData of the cursor's hot spot.}}
+
{{param|number|hotx (0)|The x-coordinate in the ImageData of the cursor's hot spot.}}
{{param|number|hoty (0)| The y-coordinate in the ImageData of the cursor's hot spot.}}
+
{{param|number|hoty (0)|The y-coordinate in the ImageData of the cursor's hot spot.}}
 
=== Returns ===
 
=== Returns ===
 
{{param|Cursor|cursor|The new Cursor object.}}
 
{{param|Cursor|cursor|The new Cursor object.}}
Line 22: Line 22:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
cursor = love.mouse.newCursor( ctype )
+
cursor = love.mouse.newCursor( filename, hotx, hoty )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|CursorType|ctype|The type of cursor to create. }}
+
{{param|string|filename|Path to the image to use for the new Cursor.}}
 +
{{param|number|hotx (0)|The x-coordinate in the image of the cursor's hot spot.}}
 +
{{param|number|hoty (0)|The y-coordinate in the image of the cursor's hot spot.}}
 +
=== Returns ===
 +
{{param|Cursor|cursor|The new Cursor object.}}
 +
 
 +
== Function ==
 +
=== Synopsis ===
 +
<source lang="lua">
 +
cursor = love.mouse.newCursor( fileData, hotx, hoty )
 +
</source>
 +
=== Arguments ===
 +
{{param|FileData|fileData|Data representing the image to use for the new Cursor.}}
 +
{{param|number|hotx (0)|The x-coordinate in the image of the cursor's hot spot.}}
 +
{{param|number|hoty (0)|The y-coordinate in the image of the cursor's hot spot.}}
 
=== Returns ===
 
=== Returns ===
 
{{param|Cursor|cursor|The new Cursor object.}}
 
{{param|Cursor|cursor|The new Cursor object.}}
=== Notes ===
 
The "image" CursorType is not a valid argument. Use the other variant of this function to create a hardware cursor using a custom image.
 
  
 
== See Also ==
 
== See Also ==
Line 36: Line 48:
 
* [[Constructs::Cursor]]
 
* [[Constructs::Cursor]]
 
[[Category:Functions]]
 
[[Category:Functions]]
{{#set:Description=Creates a new hardware [[Cursor]] object.}}
+
{{#set:Description=Creates a new hardware [[Cursor]] object from an image.}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.mouse.newCursor}}
 
{{i18n|love.mouse.newCursor}}

Revision as of 00:37, 29 October 2013

Available since LÖVE 0.9.0
This function is not supported in earlier versions.

Creates a new hardware Cursor object from an image file or ImageData.

Hardware cursors are framerate-independent and work the same way as normal operating system cursors. Unlike drawing an image at the mouse's current coordinates, hardware cursors never have visible lag between when the mouse is moved and when the cursor position updates, even at low framerates.


O.png This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused!  



Function

Synopsis

cursor = love.mouse.newCursor( imageData, hotx, hoty )

Arguments

ImageData imageData
The ImageData to use for the new Cursor.
number hotx (0)
The x-coordinate in the ImageData of the cursor's hot spot.
number hoty (0)
The y-coordinate in the ImageData of the cursor's hot spot.

Returns

Cursor cursor
The new Cursor object.

Notes

The hot spot is the point the operating system uses to determine what was clicked and at what position the mouse cursor is. For example, the normal arrow pointer normally has its hot spot at the top left of the image, but a crosshair cursor might have it in the middle.

Function

Synopsis

cursor = love.mouse.newCursor( filename, hotx, hoty )

Arguments

string filename
Path to the image to use for the new Cursor.
number hotx (0)
The x-coordinate in the image of the cursor's hot spot.
number hoty (0)
The y-coordinate in the image of the cursor's hot spot.

Returns

Cursor cursor
The new Cursor object.

Function

Synopsis

cursor = love.mouse.newCursor( fileData, hotx, hoty )

Arguments

FileData fileData
Data representing the image to use for the new Cursor.
number hotx (0)
The x-coordinate in the image of the cursor's hot spot.
number hoty (0)
The y-coordinate in the image of the cursor's hot spot.

Returns

Cursor cursor
The new Cursor object.

See Also

Other Languages