Spot the Difference - find errors
Ago

Hi,

I'm trying to find a way to spot the errors if you click outside the differences; if you do it 5 times, game is over.

i tried this code in both the pictures, but numErrorsFound increases even if you click a difference.

can you help me with this?

thank you

 

Code :

if (wade.app.numErrorsFound < wade.app.totalErrors)
{
    var err = wade.getSceneObject('err ' + wade.app.numErrorsFound);
    err.getSprite(1).setVisible(true);
    wade.app.numErrorsFound++;
    if (wade.app.numErrorsFound == wade.app.totalErrors)
    {
       alert('you lost!');
         wade.clearScene();
         wade.loadScene('home.wsc', true, function()
          {
          });
    }
    

}

1 Comment
Gio

Hi

That bit of code actually looks alright. I think the problem must be somewhere else, and it's a bit difficult to guess without seeing the whole thing.

However, my best guess is that the mouseDown event is being propagated to the background pictures, i.e. you get onMouseDown on the difference object, and then you also get onMouseDown on the object behind it.

To stop an event from propagating, simply return true in the event handler. In this case you probably want to return true from the difference object's onMouseDown function.

Post a reply
Add Attachment
Submit Reply
Login to Reply