Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Flash cc+;HTML5:在移动对象之间绘制线_Javascript_Html_Flash_Flash Cc - Fatal编程技术网

Javascript Flash cc+;HTML5:在移动对象之间绘制线

Javascript Flash cc+;HTML5:在移动对象之间绘制线,javascript,html,flash,flash-cc,Javascript,Html,Flash,Flash Cc,我是一名试图进入编码领域的动画师,我对基础知识有点执着 这是一个简单的角色行走循环,我试图用代码[arcTo]在身体[ManBody]和脚[foot01]之间绘制腿部 线条在上面画,身体在移动——但线条在每一帧上都被重绘——我该如何/在哪里stage.update();所以它只是一条线,画在舞台上,然后在运动部件之间移动 //mouse cursor stage.canvas.style.cursor = "none"; this.ManBody.mouseEnabled = false; th

我是一名试图进入编码领域的动画师,我对基础知识有点执着

这是一个简单的角色行走循环,我试图用代码[arcTo]在身体[ManBody]和脚[foot01]之间绘制腿部

线条在上面画,身体在移动——但线条在每一帧上都被重绘——我该如何/在哪里stage.update();所以它只是一条线,画在舞台上,然后在运动部件之间移动

//mouse cursor
stage.canvas.style.cursor = "none";
this.ManBody.mouseEnabled = false;
this.addEventListener("tick", fl_CustomMouseCursor.bind(this));

function fl_CustomMouseCursor() {
    this.ManBody.x = (stage.mouseX+350) * 0.5 ;
    this.ManBody.y = (stage.mouseY+200) * 0.5;
}

//line
createjs.Ticker.addEventListener("tick",fl_DrawLineCont.bind(this));
createjs.Ticker.setFPS(10);

function fl_DrawLineCont(event) {

var stroke_color = "#ff0000";
var shape =  new createjs.Shape(new createjs.Graphics().beginStroke(stroke_color)
.moveTo(this.ManBody.x, this.ManBody.y)
.arcTo(this.foot01.x, this.foot01.y, this.ManBody.x, this.ManBody.y, 50).endStroke());
this.addChild(shape);
    stage.update(event);
}

在创建每个帧的形状时,应在此帧之外创建形状,并按如下方式重新绘制图形:

var stroke_color = "#ff0000";
var graphics = new createjs.Graphics()
var shape = new createjs.Shape(graphics);
this.addChild(shape);
function fl_DrawLineCont(event)
{
    graphics.clear();
    graphics.beginStroke(stroke_color);
    graphics.moveTo(this.ManBody.x, this.ManBody.y).arcTo(this.foot01.x, this.foot01.y, this.ManBody.x, this.ManBody.y, 50).endStroke();
    stage.update(event);
}

非常感谢您的回复@ices_2它工作正常,我只需要调整一下“自动售票机”,因为它有一些奇怪的速度问题。