gpt4 book ai didi

javascript - 尝试制作游戏时我在浏览器中看不到进度

转载 作者:行者123 更新时间:2023-12-03 06:42:26 25 4
gpt4 key购买 nike

嗨,我正在尝试使用 javascript 学习游戏开发......当我在浏览器中打开 html 文件时,它是空白的,这是我不断收到的错误......

createjs-2013.12.12.min.js:13 Uncaught TypeError: f.isVisible is not a 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>

最佳答案

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

改变这个

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

到此

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

你就可以开始了。请注意在该库提供的对象之前添加 createjs.

关于javascript - 尝试制作游戏时我在浏览器中看不到进度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37896812/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com