Book Image

Lua Game Development Cookbook

By : Mario Kasuba, Mário Kašuba
Book Image

Lua Game Development Cookbook

By: Mario Kasuba, Mário Kašuba

Overview of this book

Table of Contents (16 chapters)
Lua Game Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Cursor manipulation


This recipe incorporates the basic principles of mouse cursor manipulation such as showing and hiding the mouse cursor.

Be aware that libSDL offers fairly limited support for mouse cursor images. These are constrained by using 2 bits for each pixel on an image (1 bit for data and 1 bit for mask) and by image width, which must be a multiple of 8 bits.

There's a much better way to display a mouse cursor. You can use mouse movement events to get the current mouse cursor position and draw an image on the resulting position. This gives you much more flexibility because you can use the cursor image with more than 1 bit for pixels, set up mouse movement smoothing, acceleration, and so on.

This recipe will show you how to implement a custom mouse cursor. This might be especially useful in a case where you need to emphasize an item location under the cursor.

Getting ready

LibSDL provides its own cursor drawing routine, which is turned on by default. If you want to use your own cursor...