Inspiring
May 11, 2020
Answered
HTML5 Canvas + drag line and drop
- May 11, 2020
- 3 replies
- 7673 views
A game of connecting between pieces?
Can anyone help me?
i use adobe animate type HTML5 canvas ?
ther error in my_shape1 = new Sprite;
Any genius person to help me?
var root = this;
this.stop();
stage = new createjs.Stage("my_shape1");
stage = new createjs.Stage("my_shape2");
stage = new createjs.Stage("my_shape3");
stage.update();
var currentClip = new createjs.MovieClip();
var startX = new Number;
var startY = new Number;
var select_1 = new Boolean;
var select_2 = new Boolean;
var select_3 = new Boolean;
this.stage.addEventListener("ENTER_FRAME", moveline.bind(this));
this.bline1.addEventListener("MOUSE_DOWN", drag.bind(this));
this.bline2.addEventListener("MOUSE_DOWN", drag.bind(this));
this.bline3.addEventListener("MOUSE_DOWN", drag.bind(this));
this.bline1.addEventListener("MOUSE_UP", drop_1.bind(this));
this.bline2.addEventListener("MOUSE_UP", drop_2.bind(this));
this.bline3.addEventListener("MOUSE_UP", drop_3.bind(this));
//---------------------
function drag() {
this.currentClip = MovieClip(this.Event.target);
this.startX = currentClip.x;
this.startY = currentClip.y;
this.currentClip.parent.addChild(currentClip);
this.currentClip.startDrag();
}
//-----------
function moveline() {
//----------- الخط الأول ---------
this.my_shape1.graphics.clear();
this.my_shape1.graphics.beginFill(0x39393B);
this.my_shape1.graphics.lineStyle(5, 0x39393B, 100);
this.my_shape1.graphics.moveTo(line1.x, line1.y);
this.my_shape1.graphics.lineTo(bline1.x, bline1.y);
this.addChild(my_shape1);
//----------- الخط الثاني ----------
this.my_shape2.graphics.clear();
this.my_shape2.graphics.beginFill(0x39393B);
this.my_shape2.graphics.lineStyle(5, 0x39393B, 100);
this.my_shape2.graphics.moveTo(line2.x, line2.y);
this.my_shape2.graphics.lineTo(bline2.x, bline2.y);
this.addChild(my_shape2);
//---------- الخط الثالث --------------
this.my_shape3.graphics.clear();
this.my_shape3.graphics.beginFill(0x39393B);
this.my_shape3.graphics.lineStyle(5, 0x39393B, 100);
this.my_shape3.graphics.moveTo(line3.x, line3.y);
this.my_shape3.graphics.lineTo(bline3.x, bline3.y);
this.addChild(my_shape3);
}
//////////
function drop_1() {
this.Event.target.startDrag(true);
this.my_shape1.stopDrag();
if (bline1.hitTestObject(Target_1) && select_1) {
this.b1.alpha = 1;
this.select_1 = false;
this.good_1.play();
this.bline1.removeEventListener("MOUSE_DOWN", drag.bind(this));
this.bline1.removeEventListener("MOUSE_UP", drop_1.bind(this));
this.bline1.x = Target_1.x;
this.bline1.y = Target_1.y;
} else {
this.bline1.x = startX;
this.bline1.y = startY;
this.bad_1.play();
}
}
////////////
//////////
function drop_2() {
this.Event.target.startDrag(true);
this.my_shape2.stopDrag();
if (bline2.hitTestObject(Target_2) && select_2) {
this.select_2 = false;
this.good_1.play();
this.bline2.removeEventListener("MOUSE_DOWN", drag.bind(this));
this.bline2.removeEventListener("MOUSE_UP", drop_2.bind(this));
this.bline2.x = Target_2.x;
this.bline2.y = Target_2.y;
} else {
this.bline2.x = startX;
this.bline2.y = startY;
this.bad_1.play();
}
}
////////////
//////////
function drop_3() {
this.Event.target.startDrag(true);
this.my_shape3.stopDrag();
if (bline3.hitTestObject(Target_3) && select_3) {
this.Target_3.visible = false;
this.select_3 = false;
this.good_1.play();
this.bline3.removeEventListener("MOUSE_DOWN", drag.bind(this));
this.bline3.removeEventListener("MOUSE_UP", drop_3.bind(this));
this.bline3.x = Target_3.x;
this.bline3.y = Target_3.y;
this.bline3.visible = false;
} else {
this.bline3.x = startX;
this.bline3.y = startY;
this.bad_1.play();
}
}
