Hi,

Must state I know little or nothing about javascript but am playing around trying to find my way!!

So, I've started with a memory game which works.

Now I want to trigger a different event for each specific match. That is, you match 2 oranges, you trigger event "organise", you match two pineapples, you trigger event "pineapples". Currently, you match two pics, it triggers same event.

The code I have is below. Any ideas?

Thanks Eric

// Ďthisí is the tapped cover image
var tapped = this;

// Hide the tapped cover image
tapped.animateAction(ctx, {
properties : { opacity: 0 },
duration: 500
}, function(){
tapped.hideAction(ctx);
});

// First uncovered card?
if (!window.uncovered) {
window.uncovered = tapped;
}

// Second uncovered card?
else if (tapped !== window.uncovered) {

// If the names donít match, wait 1 second
// and then show both cover images again
if (tapped.name != window.uncovered.name) {

// We wrap this in a closure because the references will change
setTimeout((function (uncovered, tapped) {
return function () {
uncovered.showAction(ctx, {}, function(){
uncovered.animateAction(ctx, {
properties : { opacity : 1 },
duration : 500
});
});
tapped.showAction(ctx, {}, function(){
tapped.animateAction(ctx, {
properties : { opacity : 1 },
duration : 500
});
});

};
})(window.uncovered, tapped), 1000);
}

// Found a pair
else {
window.found |= 0;
screen.triggerAction(ctx, { eventName: 'oranges' });

// Found all pairs?
if (++window.found == 3) {
screen.triggerAction(ctx, { eventName: 'win' });
}
}

// No card uncovered anymore
window.uncovered = null;

}