bzr branch
http://9ix.org/bzr/traderous
1
by Josh C
zoetrope 1.4 |
1 |
-- Class: Cursor |
2 |
-- A cursor is a group that follows the user's cursor. |
|
3 |
||
4 |
Cursor = Group:extend{ |
|
5 |
-- Property: hotspot |
|
6 |
-- A table with x and y offsets for the cursor. e.g. if |
|
7 |
-- you want the user to click with a center of a crosshairs |
|
8 |
-- image, set this to half the width and half the height of |
|
9 |
-- the image. |
|
10 |
hotspot = { x = 0, y = 0 }, |
|
11 |
||
12 |
new = function (self, obj) |
|
13 |
obj = self:extend(obj) |
|
14 |
the.cursor = obj |
|
15 |
if obj.onNew then obj:onNew() end |
|
16 |
return obj |
|
17 |
end, |
|
18 |
||
19 |
update = function (self, elapsed) |
|
20 |
-- follow the mouse |
|
21 |
||
22 |
self.translate.x = the.mouse.x - self.hotspot.x |
|
23 |
self.translate.y = the.mouse.y - self.hotspot.y |
|
24 |
||
25 |
Group.update(self, elapsed) |
|
26 |
end |
|
27 |
} |