【发布时间】:2013-04-16 04:05:36
【问题描述】:
全部在一个文件中
它是 html5/javascript 画布游戏的开始
似乎每个人的独奏都更好地链接库(这是一个文件) 或在创建对象时添加新对象(我这样做了)
代码在没有对象的情况下工作正常 :/
缩写代码
html codes
codes
var tempa = new asteroid(BASIC_L, 100, 300,300,0,0,2,2,0,0);
codes
function asteroid(type, hp, x, y, z, r, vx, vy, vz, vr)
{
this.type = type;
this.hp = hp;
this.x = x;
this.y = y;
this.z = z;
this.r = r;
this.vx = vx;
this.vy = vy;
this.vz = vz;
this.vr = vr;
function display(){
this.x += this.vx;
this.y += this.vy;
if(this.type == BASIC_L){
debug(this.type);
ctx.beginPath();
ctx.strokeStyle="#00fff0";
ctx.arc(this.x,this.y,100,0,2*Math.PI);
ctx.stroke();
}
}
}
//codes
function draw(){
//codes
tempa.display();
}
//codes
//html codes
【问题讨论】:
标签: javascript html google-chrome object canvas