onMoveComplete delay
pixelschaos

Hello,

 

I'm new into WADE and I must say it looks great!

 

I was watching the tutorials and particularly the Making HTML 5 games with WADE - part 2 provided by Clockwork Chilli and I want to have a delay before executing the moveTo function on an object for example:

 

this.onMoveComplete = function()
{
if (this.state == 'down')
{
this.state = 'up';
this.owner.moveTo(this.originalPosition.x, this.originalPosition.y - 40, 100);
}
else if (this.state == 'up')
{
this.state = 'down';
this.owner.moveTo(this.originalPosition.x, this.originalPosition.y + 50, 100);
}
};
 
This works fine since it doesn't have a delay, I tried this: 
setTimeout(function() { jQuery(this.owner).moveTo(this.originalPosition.x, this.originalPosition.y - 40, 100) },3000 );
 
which doesn't work. Any ideas?
 
P.S My code is exactly as on the youtube video of "Making HTML 5 games with WADE - part 2 provided by Chiliworks"
 
Ty!
All 2 Comments
pixelschaos

Never mind all I had to do is declare "this" in a seperate variable on my object and use it in my timeout function like so:

Mole = function()
{
this.state = 'down';
var obj = this;
}
function moveup() {
obj.owner.moveTo(obj.originalPosition.x, obj.originalPosition.y + 50, 100);
}
Gio

Hi pixelschaos

 

Glad you figured it out... by the way, welcome to the forums :)

 

Let us know how you're getting on, and if you have any more questions feel free to ask anything here.

Post a reply
Add Attachment
Submit Reply
Login to Reply