javascript - 画布复制多个形状
问题描述
我想将 10 添加到球的位置,但它会为复制的形状添加位置。我试图制作一个单独的功能,但它不起作用。
HTML5 代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<canvas id="Game" width="800" height="600" style="border: 1px solid #d3d3d3;
background-color: #f1f1f1;"></canvas>
<script src="Game.js"></script>
</body>
</html>
Javascript Code:
var GameCanvas = GameCanvas = document.getElementById("Game");
var GameCtx = GameCtx = GameCanvas.getContext("2d");;
var BallSprite = 50;
window.onload = function () {
setInterval(HoldSprites, 100);
}
function HoldSprites() {
BallSprite = BallSprite + 10;
GameCtx.beginPath();
GameCtx.arc(BallSprite, 50, 40, 0, 2 * Math.PI);
GameCtx.stroke();
}
解决方案
推荐阅读
- php - 如何从 amazon s3 获取具有私有访问权限的图片?
- java - 使用 BufferedReader 在 Java 中读取 .txt 文件
- sql - 项目和项目集详细信息的 SQL 查询
- python - Django ImageField:完整路径还是相对路径?
- google-cloud-platform - 从谷歌云数据存储迁移到谷歌云 sql
- php - 如何编辑此 .ini 文件以安装 slqsrv 扩展?
- flink-streaming - Flink 1.5 on yarn,如何禁用动态资源分配?
- javascript - 模块化 JS:如何传递变量和事件
- sql-server - 在同一 Amazon RDS 上创建重复的 SQL Server 数据库
- python - pip install vprof 失败