dimanche 28 février 2016

createjs hitTest works just on moving without hitting the object

when i touch the circle to the rect then alpha should be 0.1 but unfortunately alpha becomes 0.1 once i move circle . perhaps its happening for upF(e) . but i tried to keeping bold code inside all function and even outside the scope . but nothing worked.i have uploaded here http://ift.tt/21AWtqS

/* js 

var t1 = this;
t1.circle.addEventListener('mousedown', downF)
function downF(e) {
stage.addEventListener('stagemousemove', moveF);
stage.addEventListener('stagemouseup', upF);
};

function upF(e) {

    var pt = t1.globalToLocal(stage.mouseX, stage.mouseY);
if (t2.hitTest(pt.x, pt.y)) {
  t1.alpha=0.1;
}
  stage.removeAllEventListeners();
}
function moveF(e) {
t1.circle.x = stage.mouseX;
t1.circle.y = stage.mouseY;
}


// to move a rect here is the code
var t2 = this;
t2.rect.addEventListener('mousedown', downFr)

function downFr(e) {
stage.addEventListener('stagemousemove', moveFr);
stage.addEventListener('stagemouseup', upFr);
};
function upFr(e) {
stage.removeAllEventListeners();
}
function moveFr(e) {
t2.rect.x = stage.mouseX;
t2.rect.y = stage.mouseY;
}

*/

Aucun commentaire:

Enregistrer un commentaire