containsPoint doesn't take object area

0 favourites
  • 2 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)