<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
canvas{
border: 1px solid black;
background: black;
}
</style>
</head>
<body>
<canvas id="" width="600" height="400"></canvas>
</body>
<script type="text/javascript">
var canvas=document.querySelector("canvas")
var tools=canvas.getContext("2d")
var Person=function(ctx){
//绘制工具
this.ctx=ctx || document.querySelector("canvas").getContext("2d")
//图片路径
this.src="img/monster.png"
//画布的大小
this.canvasWidth=this.ctx.canvas.width
this.canvasHeight=this.ctx.canvas.height
/*行走相关参数*/
this.stepSize=10
//0:前 1:左
使用canvas完成帧动画(方向键控制行走的小人)
最新推荐文章于 2022-01-10 12:51:20 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)