I have this problem with removing objects data on easelJs.
I have a canvas where I create a segment called overlay, then I have the ability yo create and delete small points called "seeds. What I'm trying to do is store the x,y coordinates into an array only if the seeds places are in the hitarea of the overlay image.
this is the code:
function addSeed(){
seed = new createjs.Bitmap("seed.jpg");
seed.alpha = 0.5;
seed.x = stage.mouseX-10 ;
seed.y = stage.mouseY-10 ;
addSeedData();
stage.addChild(seed);
stage.update();
storex.push(seed.x);
storey.push(seed.y);
i+=1;
}
function removeSeed(){
if(stage.getNumChildren()>childCounter){
removeSeedData();
storex.pop(seed.x);
storey.pop(seed.y);
stage.removeChildAt(stage.getNumChildren()-1);
stage.update();
}
}
function addSeedData(){
overlayPt = seed.localToLocal(10, 10, overlay);
if (overlay.hitTest(overlayPt.x, overlayPt.y)== true)
{
overlaySeedDatax.push(seed.x);
overlaySeedDatay.push(seed.y);
}
}
function removeSeedData(){
if (overlay.hitTest(overlayPt.x, overlayPt.y)== true)
{
overlaySeedDatax.pop(seed.x);
overlaySeedDatay.pop(seed.y);
}
}
I can accurately add and remove seeds from innside the overlay object butttt when I add one seed inside then add another outside than add inside and then a fourth outside... then delete all the seeds, the 2 seeds still remain in the overlaySeedData array