我正在制作一个具有多个级别的平台游戏。我编写了代码,以便某个平台对象仅在其级别属性等于当前级别时才绘制并进行碰撞检测。这对于大多数只出现在一层的平台来说是好的,但我不确定如何让平台出现在所有层面(例如边框)。是否有一个数字可以放入平台字典中,该数字将等于所有整数,以便它出现在每个级别上?
我曾尝试将 level 属性设置为 true,但在 javaScript 中 true 等于 1,但不是任何其他数字。
//The dictionary for a platform
var leftBorder = {
x:0,
y:0,
width:5,
height:canvas.height,
level: ??? //the level property that needs to equal any posative integer
};
if(leftBorder.level == currentLevel){
drawPlatform(leftBorder);
}
明月笑刀无情
相关分类