Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by OLee

Hello impactors,

i had some trouble to pick entities drawn on top of other entities (ordered by the zIndex). The mouse entity selection stops at the first touching entity. Which is in most cases not the correct one. So i wrote a quick fix for this annoying behaviour.

just replace the selectEntityAt function in lib/weltmeister/edit-entities.js with this one:
selectEntityAt: function( x, y ) {
	var collected = [],i,ent;
	this.selector.pos = { x: x, y: y };

	for(i = 0; i < this.entities.length; i++ ) {
		ent = this.entities[i];
		if( ent.touches(this.selector) ) {
			collected.push(ent);
		}
	}

	collected.sort(function(a,b){
		return a.zIndex < b.zIndex;
	});

	if(collected.length && collected[0]){
		ent = collected[0];
		this.selector.offset = {x: (x - ent.pos.x + ent.offset.x), y: (y - ent.pos.y + ent.offset.y)};
		this.selectEntity( ent );
		this.wasSelectedOnScaleBorder = this.isOnScaleBorder( ent, this.selector );
		return ent;
	}

	this.selectEntity( null );
	return false;
},

1 decade ago by inkajoo

I noticed this bug too and was happy to see this solution you posted, but this doesn't seem to be working for me, I'm still getting the buggy selection. :/
Page 1 of 1
« first « previous next › last »