コードをちょっとだけ整理してクラスごとにきちんと切りだしてみたのですが、動かないです。機能よりも退化してるけど、とりあえずくまがうろちょろはする予定だったんだけど、なんでだろう?原因が良くわからず・・・。class.createをつかってSpriteを継承したクラスのサンプルコードが見たい。

以下は動かないコード。

enchant();
window.onload=function{
/
varKuma=Class.create(Sprite);
Kuma.prototype.initialize=function{
Sprite.apply(this,arguments);
this.image=game.assets['bear.gif'];/
this.x=Math.floor(Math.random()320);/x
this.y=Math.floor(Math.random()320);/y
this.xdirection=1;/x(1:,2:)
this.ydirection=1;/y(1:,2:)
/
this.addEventListener('enterframe',function{
/
if(this.action==""){
this.time++;
if(this.time>=15){/15
game.rootScene.removeChild(this);
}
return;
}
/
this.x+=Math.floor(Math.random()2)this.xdirection;
this.y+=Math.floor(Math.random()2)this.ydirection;
/
if(game.frame%20==0){
if(Math.round(Math.random())==1){
this.xdirection*=-1;
this.scaleX*=-1;
}
if(Math.round(Math.random())==1){
this.ydirection*=-1;
}
}
/
if(this.x+this.width>game.width){
this.xdirection=-1;
this.scaleX=-1;
}
if(this.y+this.height>game.height){
this.ydirection=-1;
}
if(this.x<=0){
this.xdirection=1;
this.scaleX=1;
}
if(this.y<=0){
this.ydirection=1;
}
/
if(game.frame%3==0){
this.frame++;
}
});
/
this.addEventListener('touchstart',function(e){
newKumaVoice(this.x,this.y);/
this.action=""/
this.opacity=0.5;/
this.time=0;/
});
/
game.rootScene.addChild(this);
}
/
varKumaVoice=Class.create(Label);
KumaVoice.prototype.initialize=function(x,y){
Sprite.apply(this,arguments);
this.text='';
this.x=x;
this.y=y-10;
this.time=0;
/
this.addEventListener('enterframe',function{
this.y--;
this.time++;
15
if(this.time>=15){
game.rootScene.removeChild(this);
}
});
/
game.rootScene.addChild(this);
}
/
varTime=Class.create(Label);
Time.prototype.initialize=function(){
Sprite.apply(this,arguments);
this.x=5;
this.y=5;
this.font="8px'Arial'";
this.time=0;
this.text=""+this.time+"";
/
this.addEventListener('enterframe',function{
/
if(game.running){
if(game.frame%game.fps==0){
this.time++;
this.text=""+time.time+"";
}
}
});
/
game.rootScene.addChild(this);
}
/
vargame=newGame(320,320);
game.preload('bear.gif');
game.onload=function{
/
varkumaNum=50;/
for(i=0;i<kumaNum;i++){
newKuma();
}
/
game.start();
}
};