[improve] (render) check part pixel under cursor

This commit is contained in:
2020-02-20 20:53:23 +03:00
parent 085f68d359
commit db78b5cff4
3 changed files with 22 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "puzzlez", "name": "puzzlez",
"version": "0.3.3", "version": "0.3.4",
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"dateformat": "^3.0.3", "dateformat": "^3.0.3",

View File

@@ -133,18 +133,32 @@ class Render extends SpriteView implements IRender {
} }
private function onMouseDown(event:MouseEvent):Void { private function onMouseDown(event:MouseEvent):Void {
if (Std.is(event.target, PartView)) { var point:FlashPoint = new FlashPoint(event.stageX, event.stageY);
var part:PartView = event.target; var objects = tableView.getObjectsUnderPoint(point);
objects.reverse();
var pointPart:PartView = null;
for (object in objects) {
if (Std.is(object, PartView)) {
var part:PartView = cast object;
var partPoint = part.globalToLocal(point);
var color = part.image.shadedImage.getPixel(Std.int(partPoint.x), Std.int(partPoint.y));
if (color > 0) {
pointPart = part;
break;
}
}
}
if (pointPart != null) {
if (event.ctrlKey) { if (event.ctrlKey) {
save(part); save(pointPart);
return; return;
} }
if (part.completed) { if (pointPart.completed) {
return; return;
} }
activePart = part; activePart = pointPart;
tableView.setChildIndex(activePart, tableView.numChildren - 1); tableView.setChildIndex(activePart, tableView.numChildren - 1);
activePoint = tableView.globalToLocal(new FlashPoint(event.stageX, event.stageY)); activePoint = tableView.globalToLocal(point);
tableView.stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); tableView.stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
tableView.stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); tableView.stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
signal.emit(ACTION(PART_TAKE(activePart.id))); signal.emit(ACTION(PART_TAKE(activePart.id)));

View File

@@ -1,4 +1,4 @@
* background settings * background settings
* parts groups * parts groups
* navigation * navigation
* version compare bug * render: table scale/move