在尝试制作游戏时,我无法看到眉毛的进展

时间:2016-06-18 12:15:44

标签: javascript createjs

您好我正在尝试使用javascript学习游戏开发....当我在浏览器中打开我的html文件时,它是空白的,这是我一直在犯的错误......

  

createjs-2013.12.12.min.js:13未捕获的TypeError:f.isVisible不是functionb.draw
  @ createjs-2013.12.12.min.js:13b.update
  @ createjs-2013.12.12.min.js:13window.onload @ init.js:25“

var canvas;
var stage ;
var img = new Image();
var bmpSeq;
var text;


window.onload = function()
{
   canvas = document.getElementById("myCanvas");
   context = canvas.getContext('2d');
   context.canvas.width = 900;
   context.canvas.height = 500;
   stage = new createjs.Stage(canvas);
   text =  new Text("TEXT HERE","36px Ariel","black");
   text.x =100;
   text.y = 200;
   stage.addChild(text);
   
   var circle = new createjs.Shape();
   circle.graphics.beginFill("red").drawCircle(0, 0, 50);
   circle.x = 100;
   circle.y = 100;
   stage.addChild(circle);
   stage.update();
   //img.onload = ImageLoaded;
   //img.src = "assets/dude.png" ;
 
   
}






    
function ImageLoaded(e)
{  
   //stage = new createjs.Stage("canvas");
   var  ss = new createjs.SpriteSheet({
    images : [img],
    frames : {width:32,height:64},
    animations: {
         face : 4,
         walk :  [4,8] }
    });

   //bitmap sequence
   //bmp = new createjs.BitmapAnimation(ss);
   //bmp.regX = bmp.spriteSheet.frameWidth/2|0; //reg pt in the center of the frame
  // bmp.regY = bmp.spriteSheet.frameHeight/2|0;
   //bmp.gotoAndPlay("w_r");
   
   
   //bmp.x = canvas.width/2;
   //bmp.y = canvas.height/2;
   
   stage.addChild(ss); //won't do anything yet
   //stage.update();
   

}
<!DOCTYPE html>
<html>
    <head>
        <title>GAme Trial</title>
        <link href="normalize.css" type="text/css" rel="stylesheet" />
        <script language="javascript" type="text/javascript" src="http://code.createjs.com/createjs-2013.12.12.min.js" ></script>  <!--Getting the Library-->
        <script language="javascript" type="text/javascript" src="init.js" ></script>
    </head>
    <body>
        <canvas id="myCanvas"></canvas> <!--graphical surface in which the game is played-->
    </body>
</html>

1 个答案:

答案 0 :(得分:1)

您创建了一个新的Text()对象,而不是createjs.Text()对象。

更改此

text =  new Text("TEXT HERE","36px Ariel","black");

到这个

text =  new createjs.Text("TEXT HERE","36px Ariel","black");

你很高兴去。请注意在该库提供的对象之前添加createjs.