Closed dnldd closed 11 years ago
Can you isolate what isn't working as expected? Thanks!
This is what isn't working correctly:
function Icon(path, position, size, stage){
this.skin = new Bitmap(path);
this.skin.x = position.x;
this.skin.y = position.y;
this.skin.regX = (size.length/2);
this.skin.regY = (size.height/2);
stage.addChild(this.skin);
//this.skin.onDoubleClick = function(event){ alert("click click"); }
this.skin.onClick = function(event){ alert("click"); }
this.skin.onPress = function(event){ console.log("pressing"); }
};
The commented-out onDoubleClick event works, onClick and onPress do not.
any chance you could set up a jsfiddle or similar? I'm unable to reproduce your issue, and I can't see an immediate issue glancing at your code.
Thanks!
I tried setting up a jsfiddle, didn't work out so well so I went ahead and hosted the game remotely for you to check out. it's over here: http://mobcont-pi.appspot.com/assets/bd/index.html. You'll notice that when a falling bird collides with the bird at the mouse pointer's position and it resets, clicking it does not fire the onClick event. The onClick event is set here:
function Shield(path, position, size, type, game){
this.skin = new Bitmap(path);
this.skin.x = position.x;
this.skin.y = position.y;
this.skin.regX = (size.length/2);
this.skin.regY = (size.height/2);
this.type = type;
game.stage.addChild(this.skin);
this.skin.onClick = function(event){ game.activeShield = type; console.log("selected"); }
/*this.skin.addEventListener("press", function(event){
this.parent.addChild(this);
var offset = { x : this.x - event.stageX, y : this.y - event.stageY};
event.addEventListener("mouseMove", function(event) {
console.log("moving");
this.x = event.stageX + offset.x ;
this.y = event.stageY + offset.y ;
}, this)
}); */
};
I know this setup is not ideal, sorry about that. Please do inspect with the js console. Noir.js is the file with all the easeljs code. Thanks.
@dnldd
Have you ever got the mouse events to work? After having a look at your code... I noticed that you have 2 canvases "canvas" and "debugCanvas" If you remove the debugCanvas will get those events just fine.
@sebastianderossi Nope, I haven't gotten it to work yet. I'll try what you've suggested. So that means I have to sacrifice the debug renderer for box2d to get easelJS to work properly? Is there a work-around that let's me have both?
@dnldd
Here's an easier way to deal with displaying the debug draw and the EaselJS graphics:
var DEBUG = true;
world.Step(1/24, 2, 2); world.ClearForces(); if (DEBUG) { world.DrawDebugData(); }
// ... do all your work here (updating positions, etc)
stage.autoClear = !DEBUG; // prevents EaselJS from clearing the canvas. stage.alpha = 1-DEBUG*0.6; // draws the stage graphics with appropriate alpha. stage.update();
Check out my first comment on this tutorial for one approach to handle this: http://gotoandlearn.com/play.php?id=177
Hope it helps. Grant.
On 2013-02-05, at 04:06 , Donald Adu-Poku notifications@github.com wrote:
@sebastianderossi Nope, I haven't gotten it to work yet. I'll try what you've suggested. So that means I have to sacrifice the debug renderer for box2d to get easelJS to work properly? Is there a work-around that let's me have both?
— Reply to this email directly or view it on GitHub.
Hi, I've noticed select mouse events do not trigger - onClick, onPress, drag/drop. OnDoubleClick works however. I'm running my example on a local server and using easeljs-0.5.0.min.js. This is what I'm doing:
.js file
.html file
Thanks.