i have something wrong with sprite object,but don't understand what same.
here is the code
runtime.addEventListener("pointerup", e => OnMouseDown(e, runtime)); function OnMouseDown(e, runtime){ SpritesClicked(e, runtime); } function SpritesClicked(e, runtime){ const sprites = runtime.objects.Cards_family.getAllInstances(); for(var i = 0; i < sprites.length; i++) { if(sprites[i].containsPoint(e.clientX, e.clientY)){ if (sprites[i].instVars.pushed==0) { sprites[i].instVars.pushed=1; sprites[i].y=sprites[i].y-10; } else { sprites[i].instVars.pushed=0; sprites[i].y=sprites[i].y+10; } } } }
if the browser have free space beyound workspace-i just cant find where is area of containsPoint of object.if no free space(image#2)-i can found an active space,but it's too tight,and it's at the bottom of object when "pushed"=0,and jump to the top of object when "pushed"=1.what the hell?
dropmefiles.com/8Clqf
Develop games in your browser. Powerful, performant & highly capable.
It's a mistake in your code. The clientX/clientY properties of input events are in a different co-ordinate system to the game. You need to use the layer cssPxToLayer method to convert between the co-ordinate systems.