How do I track clicks on any sprite? for example I have a sprite named
ball .How do I write a JS script that will track clicks on this object?
Use the On click and the Cursor over object conditions together. Then setup your sprite with an instance variable and add to that variable after each click.
Each instance should be keeping track of the number of times it was clicked on.
Develop games in your browser. Powerful, performant & highly capable.
Here is a quick example. https://www.dropbox.com/s/7003e5c4ajmdbjg/KeepTrackOfClicks.c3p?dl=0
Notice the instance variable ClickCount in the Sprite object type.
Additionally I used containers as a clean way to output the ClickCount variable of each instance to a different Text instance.
how do I write a click tracking function in js?
async function OnBeforeProjectStart(runtime)
{
click.spite(){
alert("11111");
}
runtime.addEventListener("tick", () => Tick(runtime));
Is this only possible with this? Or can an object get an event listener "addEventListener("click", ...)?
containsPoint(x, y)
Test if a point intersects this instance, using its collision polygon if any, and return a boolean indicating if the point is inside the instance's collision area.
Here you can find an example.
suggestion... if u don't want to use the Construct built in listeners, you can always try this
w3school event listeners