我正忙于编写游戏,但我遇到了一些问题。
我以前可以让游戏完美运行,但突然间它停止运行了。
这是给出错误的脚本部分:
var colorTransform:ColorTransform;
var player:MovieClip;
var kaas:MovieClip;
var ground:MovieClip;
var speed:Number;
var right:Boolean = false;
var left:Boolean = false;
var up:Boolean = false;
var down:Boolean = false;
var isWalking:Boolean = false;
var isJumping:Boolean = false;
var jumpSpeedLimit:int = 14;
var jumpSpeed:Number = jumpSpeedLimit;
// END
public function main()
{
speed = 5;
kaas = new Kaas();
kaas.y = 300;
kaas.x = 300;
addChild(kaas);
ground = new Ground();
ground.y = stage.stageHeight;
ground.x = stage.stageWidth / 2;
addChild(ground);
player = new Player();
player.x = stage.stageWidth / 2 - player.width;
player.y = stage.stageHeight - 45;
player.width = 50;
player.height = 50;
addChild(player);
player.gotoAndStop("idle");
//event listeners.
stage.addEventListener(KeyboardEvent.KEY_UP, keyupCheck);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keydownCheck);
player.addEventListener(Event.ENTER_FRAME, movePlayer);
}
我希望有人可以帮助我。
这是我收到的错误消息:
typeerror error #1009 cannot access a property or method of a null object reference.at main()
在此先感谢,雷米