1 decade ago by matt_nz
Hi All,
I'm trying to implement a play/pause button that can be clicked on with the mouse, to track the mouse I do:
And then for the pause button I do:
However as soon as stopRunLoop is called, the whole loop stops running, and therefore the mouse click -> clicked: function() -> startRunLoop is not run on the next click.
I feel like I might be missing something but obvious here, but I can't see any way to unpause, it seems like once I have paused, I just closed the door with the keys left inside.
Thanks,
Matt.
I'm trying to implement a play/pause button that can be clicked on with the mouse, to track the mouse I do:
EntityPointer = ig.Entity.extend
({
checkAgainst: ig.Entity.TYPE.B,
type: ig.Entity.TYPE.NONE,
size: {x:1, y:1},
isClicking: false,
init: function()
{
ig.input.initMouse();
},
update: function()
{
this.pos.x = ig.input.mouse.x;
this.pos.y = ig.input.mouse.y;
this.isClicking = ig.input.pressed('click');
},
check: function(other)
{
if( this.isClicking && typeof(other.clicked) == 'function' )
{
other.clicked();
}
}
});
And then for the pause button I do:
EntityPauseButton = ig.Entity.extend
({
size: {x: 35, y: 36},
type: ig.Entity.TYPE.B,
animSheet: new ig.AnimationSheet( 'media/images/pause.png', 35, 36 ),
paused: false,
init: function(x, y, settings)
{
this.parent(x, y, settings);
this.addAnim( 'idle', 1, [0] );
},
clicked: function()
{
if(this.paused == false)
{
this.paused = true;
ig.system.stopRunLoop();
}
else
{
ig.system.startRunLoop();
this.paused = false;
}
},
});
However as soon as stopRunLoop is called, the whole loop stops running, and therefore the mouse click -> clicked: function() -> startRunLoop is not run on the next click.
I feel like I might be missing something but obvious here, but I can't see any way to unpause, it seems like once I have paused, I just closed the door with the keys left inside.
Thanks,
Matt.
