Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

456
Vistas
I want to disable collision detection while pressing the mouse. (Matter-js)

I'm writing code using p5js, a JavaScript library.
Right now, I'm making interactive art using Matter-js, a library of physics engines.

What I want to do is divide a picture into disjointed objects and mix them using a physics engine. Then, return to the original position so that the time will return with the passage of time or with a mouse click. I want to bring the object back and restore the picture.

I want to invalidate the collision detection of the object when returning this object to the initial position. If there is a collision detection, the objects will collide and you will not be able to return to the initial position.
Does anyone know a good way?

The URL of the application in the process of being created is posted below.   https://openprocessing.org/sketch/1387403

A part of the code of p5js is below. The whole code can be seen from the above URL.

function MonaBox(img, x, y, w, h) {
    let options = {
        friction: 0,
        restitution: 0.95,
    };
    this.body = Bodies.rectangle(x, y, w, h, options);
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.img = img;
    World.add(world, this.body);
    this.pos = this.body.position;
    this.angle = this.body.angle;
    

    this.show = function() {
        push();
        translate(this.pos.x, this.pos.y);
        rotate(this.angle);
        imageMode(CENTER);
        image(this.img, 0,0,this.w, this.h);
        pop();
    };

    this.update = function(isTouched){
        if(isTouched == false){
            this.pos = this.body.position;
            this.angle = this.body.angle;
        } else {
            if(this.pos.x != this.x){
                if(this.pos.x < this.x) this.pos.x +=0.1;
                if(this.pos.x > this.x) this.pos.x -=0.1;
            }
            if(this.pos.y != this.y){
                if(this.pos.y < this.y) this.pos.y +=0.1;
                if(this.pos.y > this.y) this.pos.y -=0.1;
            }
            if(this.angle != 0){
                if(this.pos.y < 0) this.pos.y +=0.1;
                if(this.pos.y > 0) this.pos.y -=0.1;
            }
        }
    };
}

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda