html - 必须通过在我的 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>
解决方案
我不太明白你的意思。如果您尝试捕获控制台输出,这里有一个简单的示例:
var output = [];
var saved = console.log;
console.log = function(arg) {
output.push(arg);
saved(arg);
};
console.log('Hello, world!');
这样做是将内置的 console.log 方法替换为捕获控制台输出的新方法。
为什么我们有一个名为 saved 的变量是旧的 console.log 在我们替换它之前的备份,所以它仍然可以写入控制台。
推荐阅读
- c# - 在加载视图之前尝试填充模型
- apache - 如何覆盖 RewriteRules 的协议
- graphql - 订阅 AWS AppSync 中的群组/私人聊天列表
- google-cloud-platform - 谷歌云平台 - 机器学习引擎 - 花数据集
- excel - VBA 用户窗体中的“确定”命令按钮无法默认
- linux - 如何在 CentOS 上为 PHP 7 安装 json 扩展?
- node.js - 单词和空格之间的JS子字符串
- android - 当android系统会追加raw://
到用户从 android 设备中选择的任何文件? - android - 为什么我的地理围栏广播接收器中的网络访问不可靠?
- node.js - 调用 API 或登录控制台?