onMoveComplete is not working
Alp

Hi,

I am following up Making HTML5 games with WADE - part 1 using wadejs version 3.8.1. I used the same code. However, mole doesn't move up and down continously as yours.  Would you please clarify the reason.

Many thanks in advance.

Here is my code below:

App = function(){
    
    this.load = function()
    {
      wade.loadImage('mole.png');
      wade.loadImage('holeBottom.png');
      wade.loadImage('holeTop.png'); 
    };
    
    this.init = function()
    {
        var sprite = new Sprite('mole.png', 10);
        var mole = new SceneObject(sprite);
        wade.addSceneObject(mole);
        mole.setPosition(0 ,50);
        mole.moveTo(0, -40, 100);
        mole.state = 'down';
        
        mole.onMoveComplete = function()
        {
            if(mole.state =='down')
            {
                mole.state ='up';
                mole.moveTo(0, -40, 100);
            }            
            else if(mole.state =='up')
            {      
                mole.state ='down';
                mole.moveTo(0, 44, 100); 
            }
        };
        
        var holeTop = new Sprite('holeTop.png', 20);
        
        var holeBottom = new Sprite('holeBottom.png', 5);
        var hole = new SceneObject([holeTop, holeBottom]);
        hole.setSpriteOffset(0, {x:0, y:-64}) //holTop with 0 index in object array 64 up
        hole.setSpriteOffset(1, {x:0, y:64}) //holBot with 1 index in object array 64 dwn
        wade.addSceneObject(hole);
    };
};

All 2 Comments
Alp

The problem arised from two reasons:

1. I didn't include jquery script in my html file.

2. I also had to change the wade_3.8.1.js to wade_1.5.js. (?)

So, problem is solved.

Gio

Hi

Glad you solved your problem - I just wanted to add that jquery is no longer needed. It was required by wade in the past, but since version 3.4 you don't need any external libraries to use wade.

Post a reply
Add Attachment
Submit Reply
Login to Reply