Buttons overlapping.
by rennie moffat · in Torque Game Builder · 04/07/2010 (1:13 pm) · 8 replies
Essentially what I want to know is, is there a way to create a screen so to speak so that a button, floating in HUD, if over another player button (something the player can press to trigger an event) is there a way to create a screen, so that if the HUD button is over a player interactive button that both do not get triggered?
A better example may be when my game is paused a menu appears, when I press, say resumeGame, the game resumes AND my player shoots off to the position in world space where the resumeGameBtn was.
I have tried a disable if in contact, but it did not clearly work. Is the use of castCollsion the only way around this? any other methods to this madness?
A better example may be when my game is paused a menu appears, when I press, say resumeGame, the game resumes AND my player shoots off to the position in world space where the resumeGameBtn was.
I have tried a disable if in contact, but it did not clearly work. Is the use of castCollsion the only way around this? any other methods to this madness?
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
04/07/2010 (6:05 pm)
hmm. That's a great idea. I will try something like that. Thanks!
#3
What I am wondering and maybe someone can answer this for me but can I disable a class feature of an object of a class feature meaning if, and just thinking this out now but could I...
04/07/2010 (6:22 pm)
Ps one thing I will have to think about tho is that, while I think your suggestion will solve when my game is paused and I move to resume my game is virtually full of buttons, active to the touch.What I am wondering and maybe someone can answer this for me but can I disable a class feature of an object of a class feature meaning if, and just thinking this out now but could I...
///if pauseBtn touching a tileBtn of tileBtnClass /// can I make that particular tileBtn %this.tileBtn.setUseMouseEvents(false);
#4
I have made a character of my tile behavior up so that if it is touching a guiBtnClass, this includes the pause btn that I will setUSeMouseEvents(false), then run a schdule to set it to true. My thought was, that if it (the tileBtn) still in collision with the guiBtnClass object that it will, after the schedule passes it to true, instantly shut it to false again, thus making that tile virtually unsable for the player. But that does not seem to be the case. If I can get that going it would be a good enough patch solution.
So going on that logic, this code should work, should it not?
Thank.
the real thing perplexing me right now is that the echo as seen, does return 0, so the mouse events for the owner are false, yet when pressed in the game, the player reacts. That should not be the case.
04/08/2010 (6:55 am)
Update. I have made a character of my tile behavior up so that if it is touching a guiBtnClass, this includes the pause btn that I will setUSeMouseEvents(false), then run a schdule to set it to true. My thought was, that if it (the tileBtn) still in collision with the guiBtnClass object that it will, after the schedule passes it to true, instantly shut it to false again, thus making that tile virtually unsable for the player. But that does not seem to be the case. If I can get that going it would be a good enough patch solution.
So going on that logic, this code should work, should it not?
Thank.
function tileBehaviorCollTest::onCollision(%srcObject, %dstObject, %srcRef, %dstRef, %time, %normal, %contacts, %points)
{
if(%dstObject.class $= "guiBtnClass")
%srcObject.disableMouseEvents();
}
function tileBehaviorCollTest::disableMouseEvents(%this)
{
%this.owner.setUseMouseEvents(false);
%mouseEventsFalse = %this.owner.getUseMouseEvents();
echo("tileBehavior::disableMouseEvents");
echo(" %mouseEventsFalse" @ %mouseEventsFalse);
%this.schedule(3000, reableMouseEvents);
}
function tileBehaviorCollTest::reableMouseEvents(%this)
{
%this.owner.setUseMouseEvents(true);
}the real thing perplexing me right now is that the echo as seen, does return 0, so the mouse events for the owner are false, yet when pressed in the game, the player reacts. That should not be the case.
#5
it works.
thanks!
04/08/2010 (7:13 am)
Actually I have just set up a variable so if true, onmouseUp do this, if false, do that.it works.
thanks!
#6
If anyone has insight please tell. thanks,
Ren
04/08/2010 (7:37 am)
ok this system i have is too faulty. It works for when the schedule is on, but for whatever reason there is too big of a window in which the tile remains active. I am not sure why. I would expect one nanosecond when the statement is false but immediately switch back to true. this is essentially what I have. If anyone can see why or has a better explanation please tell me. thanks.onMouseUp()
{
if(%this.tileInactive == true)
doNothing;
return;
if(%this.tileInactive == false)
doThis;
}
onCollision()
{
if(%dstObject.class $= "guiBtnClass");
%srcObject.disableBtn();
}
disableBtn()
{
%this.tileInactive = true;
%this.schedule(500, reableBtn);
}
reableBtn()
{
%this.tileInactive = false;
///it is here that I would, if the 2 objects are still in contact
///that the collision would be triggered and thus tileInactive == true
/// but my player, still reacts, too often for this to be the case.
/// the weirdest thing though is that echo tells me that it tileInactive == true
// all the time so... not sure what to make of that.
///I even put this line in too thinking it would help.
%this.onCollision();
}If anyone has insight please tell. thanks,
Ren
#7
I don't have any thoughts on your overall problem though. Sorry.
04/08/2010 (1:19 pm)
Here's a thought. Every time you have a collision, you schedule a call to reableBtn. So every frame that a collision is processed, you will have another call to reableBtn queued up. Eventually you'll be enabling and disabling the button at least once every frame, it's just a question of which call happens first.I don't have any thoughts on your overall problem though. Sorry.
#8
This is what I have currently. I would think that even with out castCollision the collision, if still occurring, as in the objets "stay in physical contact, without break" that even when the schedule runs out, to reset button to active that because A. the collision is occurring and I call onCollision() (not sure if that is good programming for Torque) that the button will be set back to inActive. However, it appears that the inactive button only lasts for as long as the the schedule. It does not reset. Very frustrating.
04/08/2010 (1:54 pm)
no worries. I would like to better understand what you mean. but I think what you are saying tho is what I have done.This is what I have currently. I would think that even with out castCollision the collision, if still occurring, as in the objets "stay in physical contact, without break" that even when the schedule runs out, to reset button to active that because A. the collision is occurring and I call onCollision() (not sure if that is good programming for Torque) that the button will be set back to inActive. However, it appears that the inactive button only lasts for as long as the the schedule. It does not reset. Very frustrating.
function tileBehavior::onCollision(%srcObject, %dstObject, %srcRef, %dstRef, %time, %normal, %contacts, %points)
{
if(%dstObject.class $= "guiBtnClass")
%srcObject.disableMouseEvents();
}
function tileBehavior::disableMouseEvents(%this)
{
%this.tileInactive = true;
echo("tileBehavior::disableMouseEvents");
echo(" %this.tileInactive " @ %this.tileInactive);
%this.schedule(1000, reactivateTile);
}
function tileBehavior::reactivateTile(%this)
{
%this.tileInactive = false;
%collision = %this.owner.castCollision();
%collisionObject = getWord(%collision, 0);
if(%collionObject.class $= "guiBtnClass")
%this.disableMouseEvents();
}
Torque 3D Owner Darius
Something like this:
function showPauseMenu() { $PAUSE_MENU_VISIBLE = true; } function hidePauseMenu() { $PAUSE_MENU_VISIBLE = false; } function onMouseDown(%this,%modifier,%worldPosition,%clicks) { if(!$PAUSE_MENU_VISIBLE) { //Do Stuff } }I hope that helps.