Custom Mouse Cursor Image
by Chok Wei Tat · in Torque Game Builder · 10/13/2006 (4:27 am) · 6 replies
Hi, i hv go through the mole game example, i found that the hammer is actually follow the cursor to get the effect that we are setting the cursotr to hammer.
i wonder is there a way in tgb to set the mouse cursor to an image with jz one simple command like
%mouseObj = setMouseCursor(imageName, frameIndex);
Thanks
i wonder is there a way in tgb to set the mouse cursor to an image with jz one simple command like
%mouseObj = setMouseCursor(imageName, frameIndex);
Thanks
#2
Then use Canvas.setCursor( myCursorName ) .
10/13/2006 (4:57 pm)
See games/common/gui/cursors.cs to see how to create a new cursor image.Then use Canvas.setCursor( myCursorName ) .
#3
It worked!!
function startGame(%level)
{
Canvas.setContent(mainMenuGuid);
initCursor();
moveMap.push();
if( isFile( %level ) || isFile( %level @ ".dso")) {
echo (%level);
sceneWindow2D.loadLevel(%level);
}
}
function initCursor() {
new GuiCursor(gameCursor)
{
hotSpot = "1 1";
renderOffset = "0 0";
bitmapName = "~/data/images/buttonBack_h.png";
};
Canvas.setCursor(gameCursor);
}
10/13/2006 (7:05 pm)
ThanksIt worked!!
function startGame(%level)
{
Canvas.setContent(mainMenuGuid);
initCursor();
moveMap.push();
if( isFile( %level ) || isFile( %level @ ".dso")) {
echo (%level);
sceneWindow2D.loadLevel(%level);
}
}
function initCursor() {
new GuiCursor(gameCursor)
{
hotSpot = "1 1";
renderOffset = "0 0";
bitmapName = "~/data/images/buttonBack_h.png";
};
Canvas.setCursor(gameCursor);
}
#4
How to make the initCursor, the "gameCursor" to use one of the frame of the image?
For example, i jz want to display frame 3 as mouse cursor and not the whole image.
Dono wht the properties should put in the
new GuiCursor(gameCursor)
{
hotSpot = "1 1";
renderOffset = "0 0";
// bitmapName = "~/data/images/buttonBack_h.png";
??? ... ???
/* THIS ONE CRASH TGB
imageMap = "b2ImageMap";
frame = "0";
*/
};
Thanks
10/13/2006 (7:40 pm)
But i think i encounter prob hereHow to make the initCursor, the "gameCursor" to use one of the frame of the image?
For example, i jz want to display frame 3 as mouse cursor and not the whole image.
Dono wht the properties should put in the
new GuiCursor(gameCursor)
{
hotSpot = "1 1";
renderOffset = "0 0";
// bitmapName = "~/data/images/buttonBack_h.png";
??? ... ???
/* THIS ONE CRASH TGB
imageMap = "b2ImageMap";
frame = "0";
*/
};
Thanks
#5
10/14/2006 (4:02 pm)
I don't think mouse cursors act on cells like images do. When I ran into this problem, I wound up chopping up my tiled image into 6 different pngs, one for each cell in the image.
#6
then use this func
function sceneWindow2D::onMouseMove(%this, %mod, %worldPosition) {
myhand.setPosition(%worldPosition);
}
then i create the illusion for mouse cursor by
canvas.hidecursor();
myhand.setvisible(1);
Yeo~la, it works,
and i dont hv to create hundreds of image for setting "bitmapName" for GuiCursor
10/15/2006 (5:24 am)
I found my way, i use an transparent t2dSprite object (setVisible(0))then use this func
function sceneWindow2D::onMouseMove(%this, %mod, %worldPosition) {
myhand.setPosition(%worldPosition);
}
then i create the illusion for mouse cursor by
canvas.hidecursor();
myhand.setvisible(1);
Yeo~la, it works,
and i dont hv to create hundreds of image for setting "bitmapName" for GuiCursor
Torque Owner Michael S
or maybe u just mount your cursor image to the your cursor position
but i don't have tried it yet.
i found that it's more easier to do that in mole tutorial.
i have a principe
"i don't care whatever method i use long or short . the most important my program is finished"
hehehehhehehehe