我想使用easeljs将我的文本对象移动到画布上的矩形内。我希望文本对象一接触到矩形边界就停止移动。我怎样才能在画架上做到这一点?或者更好的使用另一个框架?还是分层帆布?在画布上洛斯这样停止画布上边界内的文本对象的拖动
我的矩形边界:
var textBoundary = new createjs.Shape();
textBoundary.graphics.beginStroke("#999");
textBoundary.graphics.setStrokeStyle(1);
textBoundary.snapToPixel = true;
textBoundary.graphics.drawRect(82, 130, 149, 240);
textBoundary.setBounds(82, 130, 149, 240);
stage.addChild(textBoundary);
stage.update();
我的牵引机代码看起来像这样直到如今
var textFront = new createjs.Text();
var t = document.getElementById("TextInput1").value;
textFront.text = t;
var draggerFront = new createjs.Container();
draggerFront.x = 160;
draggerFront.y = 130;
draggerFront.addChild(textVorne,tb);
stage.addChild(draggerFront);
draggerFront.on("pressmove",function(evt) {
evt.currentTarget.x = evt.stageX ; // here I have no idea what to
evt.currentTarget.y = evt.stageY ; // do when the dragger reaches
draggerFront.mouseMoveOutside = false; // boundary
stage.update();
});
stage.update();
预先感谢任何帮助或指针在正确的方向。
辉煌,正是我所期待的。学习的好例子,使从Flash到CreateJS的过渡变得更加容易。我仍然不能在这里投票,因此评论。谢谢。 –
如何在旋转或缩放时使其工作,如果文本是旋转的,即'textFront.rotation = 90;' - 它不再工作。 – supersan