我一直坚持这个简单的问题。我一直在四处寻找并找到了解决的问题。解决方案,但似乎无法让他们在我的最终工作。我试图将一个按钮图像作为createjs.Bitmap()对象加载到我的舞台/画布上。我完全按照文档和教程中的说明进行操作,但似乎无法将图像实际显示在画布上。这是与此相关的game.js文件:
// GLOBAL VARIABLES
var gameCanvas; // The canvas the game will be contained within
var gameStage; // The primary stage holding all of our game elements
var mainMenuContainer; // The container for the main menu elements
// INITIALIZATION METHODS
// init() - sets up the game gameStage and game elements. This gets called by the <body> onLoad() event
function init() {
// initialize gameStage to manage all of the game elements
gameStage = new createjs.Stage("gameCanvas");
// add a ticker to the gameStage object
createjs.Ticker.on("tick", gameStage);
// initialize the main menu for our game
initMainMenu();
// update the stage
gameStage.update();
}
// initMainMenu() - sets up the mainMenuContainer element and attaches all of the main menu game elements to the
// container. This is called from the main init() function when the main menu is ready to be initialized
function initMainMenu() {
// initialize the container to manage all of the elements to be displayed on the main menu
mainMenuContainer = new createjs.Container();
var mainMenuStartBitmap = new createjs.Bitmap("../static/img/gui/mainMenuStartButton.jpg");
// add all elements of the main menu to the mainMenuContainer
mainMenuContainer.addChild(
mainMenuStartBitmap
);
// add the mainMenuContainer to the gameStage
gameStage.addChild(mainMenuContainer);
// update the stage
gameStage.update();
}
有没有人看到我创建位图并将孩子添加到舞台/容器的方式有什么问题?
答案 0 :(得分:2)
更新舞台时,图片尚未加载。
你应该:
干杯。