programmer__r: If you would like to get clicks on a sprite, i think you need to use "containsPoint(x, y)". Here is an example:
I added the two sprites to a family and add a "mousedown" event. On every click it will loop through the family children and checks, if a child is under the current mouse coordinates:
async function OnBeforeProjectStart(runtime)
{
// add corresponding txtFields UID and a counter variable to instances of sprites
runtime.objects.Sprite1.getFirstInstance().txtUID = runtime.objects.txtSprite1.getFirstInstance().uid;
runtime.objects.Sprite2.getFirstInstance().txtUID = runtime.objects.txtSprite2.getFirstInstance().uid;
runtime.objects.Sprite1.getFirstInstance().myCounter = 0;
runtime.objects.Sprite2.getFirstInstance().myCounter = 0;
// add an EventListener mousedown
runtime.addEventListener("mousedown", e => OnMouseDown(e, runtime));
runtime.addEventListener("tick", () => Tick(runtime));
}
function OnMouseDown(e, runtime){
// call click functions, here you could filter wich function you want to test
SpritesClicked(e, runtime);
}
function SpritesClicked(e, runtime){
const sprites = runtime.objects.Sprites.getAllInstances();
// loops through all sprites
for(var i = 0; i < sprites.length; i++) {
// checks if sprite contains mouse x,y point
if(sprites[i].containsPoint(e.clientX, e.clientY)){
sprites[i].myCounter += 1;
runtime.getInstanceByUid(sprites[i].txtUID).text = "Clicks: " + sprites[i].myCounter.toString();
}
}
}
I think this is the way you would simulate the "Mouse on Object clicked Event".