Commit | Line | Data |
162a0989 |
1 | <div class="pod"> |
2 | <!-- INDEX START --> |
3 | <h3 id="TOP">Index</h3> |
4 | |
5 | <ul><li><a href="#NAME">NAME</a></li> |
7c40f9a1 |
6 | <li><a href="#CATEGORY">CATEGORY</a></li> |
162a0989 |
7 | <li><a href="#SYNOPSIS">SYNOPSIS</a></li> |
8 | <li><a href="#DESCRIPTION">DESCRIPTION</a></li> |
9 | <li><a href="#METHODS">METHODS</a> |
7c40f9a1 |
10 | <ul><li><a href="#new">new</a></li> |
162a0989 |
11 | </ul> |
12 | </li> |
c7e8d3c6 |
13 | <li><a href="#AUTHORS">AUTHORS</a></li> |
162a0989 |
14 | <li><a href="#SEE_ALSO">SEE ALSO</a> |
15 | </li> |
16 | </ul><hr /> |
17 | <!-- INDEX END --> |
18 | |
19 | <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p> |
20 | <div id="NAME_CONTENT"> |
801213bd |
21 | <p>SDL::Cursor - Mouse cursor structure</p> |
7c40f9a1 |
22 | |
23 | </div> |
24 | <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p> |
25 | <div id="CATEGORY_CONTENT"> |
26 | <p>Core, Mouse, Structure</p> |
162a0989 |
27 | |
28 | </div> |
29 | <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
30 | <div id="SYNOPSIS_CONTENT"> |
7c40f9a1 |
31 | <pre> my $cursor = SDL::Cursor->new( |
32 | \@data, |
33 | \@mask, |
34 | $width, |
35 | $height, |
36 | $hotspot_left, |
801213bd |
37 | $hotspot_top |
38 | ); |
7c40f9a1 |
39 | |
40 | SDL::Mouse::set_cursor($cursor); |
162a0989 |
41 | |
42 | </pre> |
43 | |
44 | </div> |
45 | <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p> |
46 | <div id="DESCRIPTION_CONTENT"> |
801213bd |
47 | <p>The <code>SDL::Cursor</code> module handles mouse cursors, and allows the developer to use custom-made cursors. |
48 | Note that cursors can only be in black and white.</p> |
162a0989 |
49 | |
50 | </div> |
51 | <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
52 | <div id="METHODS_CONTENT"> |
53 | |
54 | </div> |
7c40f9a1 |
55 | <h2 id="new">new</h2> |
56 | <div id="new_CONTENT"> |
801213bd |
57 | <pre> my $cursor = SDL::Cursor->new( |
58 | \@data, \@mask, $width, $height, $hotspot_left, $hotspot_top |
59 | ); |
60 | |
61 | </pre> |
62 | <p>Create a cursor using the specified data and mask (in MSB format). |
63 | The cursor is created in black and white according to the following:</p> |
7c40f9a1 |
64 | <pre> Data / Mask Resulting pixel on screen |
65 | 0 / 1 White |
66 | 1 / 1 Black |
67 | 0 / 0 Transparent |
68 | 1 / 0 Inverted color if possible, black if not. |
162a0989 |
69 | |
7c40f9a1 |
70 | </pre> |
801213bd |
71 | <p>If you want to have color cursor, then this function is not for you. |
72 | Instead, you should hide the cursor with <code>SDL::Mouse::show_cursor(SDL_DISABLE)</code>. |
73 | Then in your main loop, when you draw graphics, draw a <code>SDL::Surface</code> at the location of the mouse cursor.</p> |
7c40f9a1 |
74 | <p>Example:</p> |
75 | <pre> use SDL; |
7c40f9a1 |
76 | use SDL::Video; |
801213bd |
77 | use SDL::Mouse; |
78 | use SDL::Cursor; |
37af21e0 |
79 | |
7c40f9a1 |
80 | SDL::init(SDL_INIT_VIDEO); |
801213bd |
81 | SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE); |
37af21e0 |
82 | |
7c40f9a1 |
83 | my @data = ( |
84 | 0b00000000, |
85 | 0b00111100, |
86 | 0b01111110, |
87 | 0b01111110, |
88 | 0b01111110, |
89 | 0b01111110, |
90 | 0b00111100, |
91 | 0b00000000 |
92 | ); |
7c40f9a1 |
93 | my @mask = ( |
94 | 0b00111100, |
95 | 0b01111110, |
96 | 0b11100111, |
97 | 0b11000011, |
98 | 0b11000011, |
99 | 0b11100111, |
100 | 0b01111110, |
101 | 0b00111100 |
102 | ); |
801213bd |
103 | my $cursor = SDL::Cursor->new(\@data, \@mask, 8, 8, 0, 0); |
7c40f9a1 |
104 | sleep(1); |
7c40f9a1 |
105 | |
801213bd |
106 | SDL::Mouse::set_cursor($cursor); |
7c40f9a1 |
107 | sleep(5); |
108 | |
109 | </pre> |
801213bd |
110 | <p>The width of cursors work in groups of 8. |
111 | If the width is above 8, twice the amount of elements in <code>@data</code> and <code>@mask</code> are required. |
112 | If the width is above 16, three times are required, and so on. |
113 | For example, if you wanted a 9 pixel crosshair you might do the following:</p> |
114 | <pre> my @data = ( |
115 | 0b00001000,0b00000000, |
116 | 0b00001000,0b00000000, |
117 | 0b00001000,0b00000000, |
118 | 0b00001000,0b00000000, |
119 | 0b11111111,0b10000000, |
120 | 0b00001000,0b00000000, |
121 | 0b00001000,0b00000000, |
122 | 0b00001000,0b00000000, |
123 | 0b00001000,0b00000000, |
124 | ); |
125 | my @mask = @data; |
126 | |
127 | my $cursor = SDL::Cursor->new(\@data, \@mask, 9, 9, 4, 4); |
128 | |
129 | </pre> |
130 | <p>The hotspot is offset by 4 pixels because a crosshair clicks from the center instead of the top left.</p> |
37af21e0 |
131 | |
132 | </div> |
c7e8d3c6 |
133 | <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
134 | <div id="AUTHORS_CONTENT"> |
1dbe1697 |
135 | <p>See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a>.</p> |
c7e8d3c6 |
136 | |
137 | |
138 | |
139 | |
162a0989 |
140 | |
141 | </div> |
142 | <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p> |
143 | <div id="SEE_ALSO_CONTENT"> |
55bbf7a2 |
144 | <p><a href="http://search.cpan.org/perldoc?perl">perl</a> <a href="SDL-Mouse.html">SDL::Mouse</a></p> |
162a0989 |
145 | |
146 | </div> |
147 | </div> |