Collision Dillema
by Michael S · in Torque Game Builder · 10/23/2006 (5:50 am) · 6 replies
Hi i've some trouble on Gui+Collision problem
i analyze that if i have gui bitmap control
and if i move my camera view ,the gui bitmap control also follow at the exact position
so like this
a = my gui bitmap control
a is inside the camera view (small box)
======================
|...............a............|.................|
|.............................|.................|
|.............................|.................|
|_______________|................|
|................................................|
|................................................|
|________________________|
if i move my camera view
this that would be happen
======================
|................................................|
|................................................|
|_______________..................|
|...............a............|.................|
|.............................|.................|
|.............................|.................|
|_______________|................|
the problem is
i have a player that have my camera mounted on it and
i have a window status on top that contains info about life score
and i want my window status behave like the gui bitmap control above
so like this
aaaaaaaaaaa= my window status
p= my player
======================
|aaaaaaaaaaaaaa.|.................|
|.............................|.................|
|....................p........|.................|
|_______________|................|
|................................................|
|................................................|
|________________________|
and if i move my player then it like this
======================
|................................................|
|................................................|
|_______________..................|
|aaaaaaaaaaaaaa.|.................|
|.............................|.................|
|.................p...........|.................|
|_______________|................|
i create the windowstatus by using guibitmapcontrol
but the problem is if i use guibitmap control my player can override my windowstatus
aaaaaapaaaaaa =====> i don't want it
so i think the window status should be created as t2dsceneobject so i can detect collision and set it to clamp with my player ,so my player can't override my windowstatus
but the problem is i having a difficulty to set my windowstatus position if my camera move
is there anybody can help me to solve this?
i analyze that if i have gui bitmap control
and if i move my camera view ,the gui bitmap control also follow at the exact position
so like this
a = my gui bitmap control
a is inside the camera view (small box)
======================
|...............a............|.................|
|.............................|.................|
|.............................|.................|
|_______________|................|
|................................................|
|................................................|
|________________________|
if i move my camera view
this that would be happen
======================
|................................................|
|................................................|
|_______________..................|
|...............a............|.................|
|.............................|.................|
|.............................|.................|
|_______________|................|
the problem is
i have a player that have my camera mounted on it and
i have a window status on top that contains info about life score
and i want my window status behave like the gui bitmap control above
so like this
aaaaaaaaaaa= my window status
p= my player
======================
|aaaaaaaaaaaaaa.|.................|
|.............................|.................|
|....................p........|.................|
|_______________|................|
|................................................|
|................................................|
|________________________|
and if i move my player then it like this
======================
|................................................|
|................................................|
|_______________..................|
|aaaaaaaaaaaaaa.|.................|
|.............................|.................|
|.................p...........|.................|
|_______________|................|
i create the windowstatus by using guibitmapcontrol
but the problem is if i use guibitmap control my player can override my windowstatus
aaaaaapaaaaaa =====> i don't want it
so i think the window status should be created as t2dsceneobject so i can detect collision and set it to clamp with my player ,so my player can't override my windowstatus
but the problem is i having a difficulty to set my windowstatus position if my camera move
is there anybody can help me to solve this?
#2
So, using a similar diagram, you would set the world limits to be something like:
10/23/2006 (3:38 pm)
You could just leave your HUD as a GUI control and then update the world limits of the player every frame to contain it within a certain area of the window. So, using a similar diagram, you would set the world limits to be something like:
==================== ____________________ [ ] [ ] [ ] [ ] [ ] ====================
#3
just like feeding frenzy / feeding frenzy 2 the fish player can't override the window status but
the window status always show on top even my camera move
hmm i think i will try your suggestion joe rossi.pray it will be worked
hmm thomas what do you mean by HUD ?
hmm i've tried to change my world limit every time but i'm have a difficulty to set the position of my player world limit
i can't use a getcameraposition and getcameraarea to set my world limit because the camera position always change and doesn't bound with the setviewlimit on
here is my current script
game.cs
function startGame(%level)
{exec("./beelevel.cs");
exec("./bee.cs");
Canvas.setContent(mainscreenGui);
Canvas.setCursor(DefaultCursor);
$wind=scenewindow2d;
// Canvas.hideCursor();
moveMap.push();
sceneWindow2D.setUseObjectMouseEvents( true );
if( isFile( %level ) || isFile( %level @ ".dso"))
sceneWindow2D.loadLevel(%level);
scenewindow2d.setviewlimiton(-100,-75,220,150);
scenewindow2d.mount(mybee,0,0,1,false);
$wind.setlockMouse(true);
lockMouse(true);
}
on my beelevel.cs this is my script
function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{
$nx=(getword(%worldPosition,0));
$ny=(getword(%worldPosition,1));
if (mybee.getflipx()==true && $nx>mybee.getpositionx()+1)
{mybee.setflipx(false);}
else if (mybee.getflipx()==false && $nx
{mybee.setflipx(true);}
}
function Beelevel::onUpdateScene(%this)
{
mybee.moveto($nx SPC $ny, 90,true,true);
// i tried this and that is a mess
//%nx=getword(scenewindow2d.getcurrentcameraposition(),1); ==>
//%nx=%nx-20;
//mybee.worldlimitmin="-105 " @ %nx ;
}
10/24/2006 (7:09 am)
Oh i just want to create a window status always that show on top of my camera but don't want my player to override it , so if i use gui control my player can override itjust like feeding frenzy / feeding frenzy 2 the fish player can't override the window status but
the window status always show on top even my camera move
hmm i think i will try your suggestion joe rossi.pray it will be worked
hmm thomas what do you mean by HUD ?
hmm i've tried to change my world limit every time but i'm have a difficulty to set the position of my player world limit
i can't use a getcameraposition and getcameraarea to set my world limit because the camera position always change and doesn't bound with the setviewlimit on
here is my current script
game.cs
function startGame(%level)
{exec("./beelevel.cs");
exec("./bee.cs");
Canvas.setContent(mainscreenGui);
Canvas.setCursor(DefaultCursor);
$wind=scenewindow2d;
// Canvas.hideCursor();
moveMap.push();
sceneWindow2D.setUseObjectMouseEvents( true );
if( isFile( %level ) || isFile( %level @ ".dso"))
sceneWindow2D.loadLevel(%level);
scenewindow2d.setviewlimiton(-100,-75,220,150);
scenewindow2d.mount(mybee,0,0,1,false);
$wind.setlockMouse(true);
lockMouse(true);
}
on my beelevel.cs this is my script
function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{
$nx=(getword(%worldPosition,0));
$ny=(getword(%worldPosition,1));
if (mybee.getflipx()==true && $nx>mybee.getpositionx()+1)
{mybee.setflipx(false);}
else if (mybee.getflipx()==false && $nx
}
function Beelevel::onUpdateScene(%this)
{
mybee.moveto($nx SPC $ny, 90,true,true);
// i tried this and that is a mess
//%nx=getword(scenewindow2d.getcurrentcameraposition(),1); ==>
//%nx=%nx-20;
//mybee.worldlimitmin="-105 " @ %nx ;
}
#4
10/25/2006 (10:26 pm)
Oh never mind i've figured it out thanks all
#5
Knowledge is power.
10/25/2006 (10:49 pm)
Mind sharing in case someone else runs into the same issue they can simply refer back to this post?Knowledge is power.
#6
i just limit my camera position
don't rely on setviewlimiton
because the cameraposition is'nt valid
so you must know manually where is the camera position is limited
in here i knew that my windowstatus is ycameraposition - 60 to keep it always on top
here is my script
function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{
%ycam=getword(scenewindow2d.getcurrentcameraposition(),1);
if ((%ycam>=-30) && (%ycam<=90)) // ===> i limit it manually
{
windowstatus.setposition(60,%ycam-60);
}
$nx=(getword(%worldPosition,0));
$ny=(getword(%worldPosition,1));
if (mybee.getflipx()==true && $nx>mybee.getpositionx()+1)
{mybee.setflipx(false);}
else if (mybee.getflipx()==false && $nx
{mybee.setflipx(true);}
}
%ycam=getword(scenewindow2d.getcurrentcameraposition(),1);// ===> i limit it manually
if ((%ycam>=-30) && (%ycam<=90))
{
windowstatus.setposition(60,%ycam-60);
}
}
function Beelevel::onUpdateScene(%this)
{
%ycam=getword(scenewindow2d.getcurrentcameraposition(),1);// ===> i limit it manually
if ((%ycam>=-30) && (%ycam<=90))
{
windowstatus.setposition(60,%ycam-60);
}
mybee.moveto($nx SPC $ny, 90,true,true);
%ycam=getword(scenewindow2d.getcurrentcameraposition(),1);
if ((%ycam>=-30) && (%ycam<=90)) // ===> i limit it manually
{
windowstatus.setposition(60,%ycam-60);
}
}
10/26/2006 (7:56 am)
Oh ok i just limit my camera position
don't rely on setviewlimiton
because the cameraposition is'nt valid
so you must know manually where is the camera position is limited
in here i knew that my windowstatus is ycameraposition - 60 to keep it always on top
here is my script
function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{
%ycam=getword(scenewindow2d.getcurrentcameraposition(),1);
if ((%ycam>=-30) && (%ycam<=90)) // ===> i limit it manually
{
windowstatus.setposition(60,%ycam-60);
}
$nx=(getword(%worldPosition,0));
$ny=(getword(%worldPosition,1));
if (mybee.getflipx()==true && $nx>mybee.getpositionx()+1)
{mybee.setflipx(false);}
else if (mybee.getflipx()==false && $nx
}
%ycam=getword(scenewindow2d.getcurrentcameraposition(),1);// ===> i limit it manually
if ((%ycam>=-30) && (%ycam<=90))
{
windowstatus.setposition(60,%ycam-60);
}
}
function Beelevel::onUpdateScene(%this)
{
%ycam=getword(scenewindow2d.getcurrentcameraposition(),1);// ===> i limit it manually
if ((%ycam>=-30) && (%ycam<=90))
{
windowstatus.setposition(60,%ycam-60);
}
mybee.moveto($nx SPC $ny, 90,true,true);
%ycam=getword(scenewindow2d.getcurrentcameraposition(),1);
if ((%ycam>=-30) && (%ycam<=90)) // ===> i limit it manually
{
windowstatus.setposition(60,%ycam-60);
}
}
Torque Owner Joe Rossi
Indri Games
When you mount the camera to the player, have you tried mounting the GUI to the player too? You can try that. You will have to give it offsets though.