Hundreds of features to explore
Games made in Construct
Your questions answered
Trusted by schools and universities worldwide
Free education resources to use in the classroom
Students do not need accounts with us
What we believe
We are in this together
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
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?
Develop games in your browser. Powerful, performant & highly capable.
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.
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