Jump to content

[Phaser3] Fire overlap just once - dragable objects


Oliver77
 Share

Recommended Posts

Hi I, use this for dragable objects:

this.physics.add.overlap(rec, puzzleGroup, overlap,null,this);

I have the problem that it is firing continuously.

What do I have to do to make it firing just once so a variable is set true if the Element is over the sprite and if it’s not above the sprite the variable set to false.

Thanks for feedback!

Link to comment
Share on other sites

Hi for my purpose I don't have to use physics. Instead I use this:
in rec are my rectangles stored.

 

this.input.on('dragend', function (pointer, gameObject) {
       
       for(i=0;i<rec.length;i++) {
             var boundsA = gameObject.getBounds();
	         var boundsB = rec[i].getBounds();
                                      
	   if(Phaser.Geom.Intersects.RectangleToRectangle(boundsA, boundsB) ){
            console.log("it's over retangle: "+rec[i].x + " it's over gameObjekt: "+ gameObject.x)  
          
           }
           else {
               console.log("its out")
           }          
       } 
 });

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...