better mouseover mapitem mvt stop
This commit is contained in:
parent
ef0d8cedf6
commit
43290d3c5d
@ -1256,15 +1256,18 @@ export default {
|
||||
// hightlight superposed entites on focus
|
||||
let entites_superposes = this.paper_main_object.children['entites_superposes'];
|
||||
// console.log('entites_superposes.children', entites_superposes.children);
|
||||
for(let paper_item of entites_superposes.children) {
|
||||
if (this.is_hover) {
|
||||
paper_item.definition = this.paper_symbol_definitions.entite_hover;
|
||||
paper_item.scale(2)
|
||||
} else {
|
||||
paper_item.definition = this.paper_symbol_definitions.entite;
|
||||
paper_item.scale(0.5)
|
||||
if(entites_superposes){
|
||||
for(let paper_item of entites_superposes.children) {
|
||||
if (this.is_hover) {
|
||||
paper_item.definition = this.paper_symbol_definitions.entite_hover;
|
||||
paper_item.scale(2)
|
||||
} else {
|
||||
paper_item.definition = this.paper_symbol_definitions.entite;
|
||||
paper_item.scale(0.5)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
// PAPER EVENTS
|
||||
initPaperEvents(){
|
||||
@ -1625,14 +1628,19 @@ export default {
|
||||
) {
|
||||
this.pushAside()
|
||||
}
|
||||
} else if (this.map_mode === 'proximite'
|
||||
|| this.map_mode === 'superposition'
|
||||
|| this.map_mode === 'puissancedagir'
|
||||
|| this.map_mode === 'action'
|
||||
|| this.map_mode === 'doleancer'){ // apply focus forces : move unfocused on the sides and focused on the center
|
||||
this.applyFocusForces(); //
|
||||
} else if (!this.is_hover){
|
||||
if (this.map_mode === 'proximite'
|
||||
|| this.map_mode === 'superposition'
|
||||
|| this.map_mode === 'puissancedagir'
|
||||
|| this.map_mode === 'action'
|
||||
|| this.map_mode === 'doleancer'){ // apply focus forces : move unfocused on the sides and focused on the center
|
||||
this.applyFocusForces(); //
|
||||
} else {
|
||||
this.applyNormalForces(); // if terrain de vie apply force to gently reject items from the sides and so create a continuasly mvmt
|
||||
}
|
||||
} else {
|
||||
this.applyNormalForces(); // if terrain de vie apply force to gently reject items from the sides and so create a continuasly mvmt
|
||||
// stop movement if is mouse hover
|
||||
Matter.Body.setVelocity(this.body, {x:0, y:0})
|
||||
}
|
||||
|
||||
// reset all matter rotation forces otherwise items will spin when colide
|
||||
@ -1951,18 +1959,8 @@ export default {
|
||||
onAfterEngineUpdate (event) {
|
||||
this.respawn();
|
||||
|
||||
// stop item on mouse hover
|
||||
// if (this.hover_elmt && this.hover_elmt.id === this.id) {
|
||||
// // Matter.Body.setStatic(this.body, true);
|
||||
// } else {
|
||||
// // Matter.Body.setStatic(this.body, false);
|
||||
// }
|
||||
if (this.is_hover) { // if mouse hover reset the matter body position to prev position
|
||||
Matter.Body.setPosition(this.body, {x:this.pos.x, y:this.pos.y}, true);
|
||||
}else{ // else move following the matter body position
|
||||
this.paper_main_object.position = this.pos = this.body.position;
|
||||
}
|
||||
|
||||
this.paper_main_object.position = this.pos = this.body.position;
|
||||
|
||||
this.handlePaperVisibilityOnAfterEnginUpdate()
|
||||
|
||||
},
|
||||
|
@ -1191,34 +1191,36 @@ export default {
|
||||
|
||||
},
|
||||
onAfterEngineUpdate(){
|
||||
|
||||
// // START OF DEBUGGING
|
||||
// // draw lines of constraints for debuging
|
||||
// let constraints_lines = this.paper.project.getItem({name: 'constraints_lines', class: paper.Group});
|
||||
// if (constraints_lines) {
|
||||
// constraints_lines.removeChildren();
|
||||
// }else{
|
||||
// constraints_lines = new paper.Group({
|
||||
// pivot: new paper.Point({x:0,y:0}),
|
||||
// name: 'constraints_lines',
|
||||
// });
|
||||
// }
|
||||
// let all_constrains = Matter.Composite.allConstraints(this.world);
|
||||
// let children = [];
|
||||
// for(let constraint of all_constrains){
|
||||
// // console.log('constrain', constraint);
|
||||
// let pointAWorld = Matter.Constraint.pointAWorld(constraint);
|
||||
// let pointBWorld = Matter.Constraint.pointBWorld(constraint);
|
||||
// // console.log('pointAWorld, pointBWorld', pointAWorld, pointBWorld);
|
||||
// children.push(new paper.Path.Line({
|
||||
// from: [pointAWorld.x, pointAWorld.y],
|
||||
// to: [pointBWorld.x, pointBWorld.y],
|
||||
// strokeColor: '#f00',
|
||||
// strokeWidth: 1
|
||||
// }));
|
||||
// }
|
||||
// constraints_lines.addChildren(children);
|
||||
// this.debugDrawConstraints()
|
||||
// // END OF DEBUGGING
|
||||
},
|
||||
debugDrawConstraints(){
|
||||
// draw lines of constraints for debuging
|
||||
let constraints_lines = this.paper.project.getItem({name: 'constraints_lines', class: paper.Group});
|
||||
if (constraints_lines) {
|
||||
constraints_lines.removeChildren();
|
||||
}else{
|
||||
constraints_lines = new paper.Group({
|
||||
pivot: new paper.Point({x:0,y:0}),
|
||||
name: 'constraints_lines',
|
||||
});
|
||||
}
|
||||
let all_constrains = Matter.Composite.allConstraints(this.world);
|
||||
let children = [];
|
||||
for(let constraint of all_constrains){
|
||||
// console.log('constrain', constraint);
|
||||
let pointAWorld = Matter.Constraint.pointAWorld(constraint);
|
||||
let pointBWorld = Matter.Constraint.pointBWorld(constraint);
|
||||
// console.log('pointAWorld, pointBWorld', pointAWorld, pointBWorld);
|
||||
children.push(new paper.Path.Line({
|
||||
from: [pointAWorld.x, pointAWorld.y],
|
||||
to: [pointBWorld.x, pointBWorld.y],
|
||||
strokeColor: '#f00',
|
||||
strokeWidth: 1
|
||||
}));
|
||||
}
|
||||
constraints_lines.addChildren(children);
|
||||
}
|
||||
},
|
||||
beforeUpdate () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user