我不知道我的代码出了什么问题。我对javascript非常陌生。有时候createjs可以工作,有时候不行,这没有意义,因为我是从别人的教程中复制完全一样的代码。
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src = "http://code.createjs.com/createjs-2013.12.12.min.js"></script>
<script>
var stage;
function init(){
stage = new createjs.Stage("myCanvas");
var ball = new createjs.Shape();
ball.graphics.beginFill("000000").drawCircle(0,0,50);
ball.x = 50;
ball.y = 200;
stage.addChild(ball);
}
</script>
</head>
<body onload = "init()">
<canvas id = "myCanvas" width = "500" height = "500">
</canvas>
</body>
</html>发布于 2014-10-30 20:04:51
即使你已经解决了你的问题,我也会稍微改进你的代码。你不需要把这个标记为正确的答案,因为你已经自己解决了。
<html>
<head>
<title>Example</title>
<script src="http://code.createjs.com/createjs-2013.12.12.min.js"></script>
<script>
var stage;
function init(){
stage = new createjs.Stage("myCanvas");
var ball = new createjs.Shape();
ball.graphics.beginFill("000000").drawCircle(0,0,50);
ball.x = 50;
ball.y = 200;
ball.cache(-50, -50, 100, 100); // -50 is -radius, 100 is radius*2
stage.addChild(ball);
stage.update();
}
</script>
</head>
<body onload="init()">
<canvas id="myCanvas" width="500" height="500">Do you even HTML5?</canvas>
</body>
</html><canvas>和</canvas>标签之间,您可以将其更改为您喜欢的任何内容。发布于 2015-11-05 03:08:22
我看不到在任何地方你可以在舞台上调用update()来绘制它。事实上,最令人费解的是为什么你说这段代码有时还能工作。它应该不会在屏幕上显示任何东西。
编辑:我看到你发表了一个评论,你说你想通了。那就算了吧。
https://stackoverflow.com/questions/26638773
复制相似问题