0
是否可以将鼠标事件添加到形状遮罩?我有面具工作,并在其他测试中使其动画。但是现在我想知道是否可以点击并拖动蒙版。是否可以使用EaselJs将鼠标/触摸事件应用于蒙版?
您可以在这里看到的例子:http://www.webnamehere.com/mask/mask.html
虽然Easeljs从未似乎永远不会的jsfiddle工作,你也可以在这里看到的代码:http://jsfiddle.net/8kbu3/1/
var circle = new createjs.Shape();
var Galaxy;
$(document).ready(function() {
canvasWidth = "1024px";
canvasHeight = "768px";
stage = new createjs.Stage('demoCanvas');
createjs.Touch.enable(stage);
$("#demoCanvas").attr({width:canvasWidth, height:canvasHeight});
Galaxy = new Image();
Galaxy.src = "images/galaxy.jpg";
Galaxy.onload = handleImageLoad;
function handleImageLoad() {
GalaxyBitmap = new createjs.Bitmap(Galaxy);
GalaxyBitmap.x = 0;
GalaxyBitmap.y = 0;
containerGalaxy = new createjs.Container();
containerGalaxy.addChild(GalaxyBitmap);
containerGalaxy.x = 0;
containerGalaxy.y = 0;
circle = new createjs.Shape();
circle.graphics.beginFill('blue').drawCircle(80,80,50).endFill();
containerGalaxy.mask = circle;
stage.addChild(containerGalaxy);
stage.update();
}
circle.onClick = function(evt){
alert('what the F?');
}
circle.onPress = function(evt){
var offset = {x:circle.x-evt.stageX, y:circle.y-evt.stageY};
evt.onMouseMove = function(ev) {
circle.x = ev.stageX+offset.x;
circle.y = ev.stageY+offset.y;
console.log("circle X: " + circle.x + " | Y: " + circle.y);
stage.update();
}
}
谢谢你们
这个答案是正确的。我在这里的EaselJS社区网站上回答了这个问题,其中包括一个修改过的示例.http://community.createjs.com/discussions/createjs/532-is-it-possible-to-to-apply-mousetouch-events-to-masks – Lanny