Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

453
Views
Quiero deshabilitar la detección de colisiones mientras presiono el mouse. (Materia-js)

Estoy escribiendo código usando p5js , una biblioteca de JavaScript.
En este momento, estoy creando arte interactivo con Matter-js , una biblioteca de motores de física.

Lo que quiero hacer es dividir una imagen en objetos inconexos y mezclarlos usando un motor de física. Luego, regresa a la posición original para que el tiempo regrese con el paso del tiempo o con un clic del mouse. Quiero recuperar el objeto y restaurar la imagen.

Quiero invalidar la detección de colisión del objeto al devolver este objeto a la posición inicial. Si hay una detección de colisión, los objetos chocarán y no podrá volver a la posición inicial.
¿Alguien sabe una buena manera?

La URL de la aplicación en proceso de creación se publica a continuación. https://openprocessing.org/sketch/1387403

A continuación se muestra una parte del código de p5js. El código completo se puede ver en la URL anterior.

 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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!