首页 > 解决方案 > 必须通过在我的 html 文件中使用 create.js 来获取输出?

问题描述

*我尝试使用 createjs 创建圆圈以进行初始 html 游戏开发在此代码中,绘图 API 或 create.js 允许动态绘制对象 *

enter code here

<html>
<head>
    <title>HTML5 Course</title>
    <script src="https://code.createjs.com/1.0.0/createjs.min.js"></script>
</head>
<body onload="init();">
    <canvas id="testCanvas" width="500" height="500"></canvas>
    <script>
        function init()
        {
            var stage = new createjs.stage("testCanvas");
            var circle = new createjs.Shape();
            circle.graphics.beginFill("Red").dreawCircle(0,0,90);**
            circle.x=250;**changing x axis**
            circle.y=250;**changing y axis**
            stage.addChild(circle); **Placing X,Y on the stage**
            stage.update();
        }
    </script>
</body>
</html>

标签: htmlcreatejs

解决方案


我不太明白你的意思。如果您尝试捕获控制台输出,这里有一个简单的示例:

var output = [];
var saved = console.log;
console.log = function(arg) {
  output.push(arg);
  saved(arg);
};

console.log('Hello, world!');

这样做是将内置的 console.log 方法替换为捕获控制台输出的新方法。

为什么我们有一个名为 saved 的变量是旧的 console.log 在我们替换它之前的备份,所以它仍然可以写入控制台。


推荐阅读