sample 我想用鼠标在舞台上画一个矩形,但是矩形不能改变大小。
这是代码:
var planetText,selectBox=new createjs.Shape(),x, y, width, height;
stage.on('mousedown',function(event){
x = event.stageX;y = event.stageY;
selectBox.graphics.beginFill('#ffffff').drawRect(x, y, 100, 100);
selectBox.set({alpha:0.5});
planetText = new createjs.Text(x+','+y +','+0+','+0, "16px Arial", "#ffffff");
planetText.set({textAlign:'center',textBaseline:'middle',x:x,y:y});
//console.log(selectBox);
stage.addChild(selectBox);
stage.addChild(planetText);
stage.update();
});
stage.addEventListener('pressmove',function (event){
//console.log(event);
width = event.stageX - x;
height = event.stageY - y;
planetText.text = x + ',' + y +','+width+','+height;
//selectBox.set({w:width,h:height});
createjs.Tween.get(selectBox).to({width:width,height:height},100,createjs.Ease.bounceIn());
stage.update();
});
stage.on('pressup',function(event){
//console.log(self.selectBox);
createjs.Tween.get(selectBox).to({alpha:0},300,createjs.Ease.bounceIn());
stage.removeChild(selectBox);
stage.update();
});
如何解决它,thx~
答案 0 :(得分:0)
看看这个问题/答案: Change Color of Shape Mid Tween
基本上,EaselJS中没有显示对象的宽度/高度,但您可以随时更改实际的绘图命令。您还可以更改scaleX / scaleY,并将笔画设置为ignoreScale
:
shape.graphics.setStrokeStyle(1, null, null, null, true); // 5th param
进一步阅读: