我的问题是 _saw in the flash 我正在做的只是与 _player 一起移动,不像 _boundary(floor) 在舞台上只是静态的
public class PiggyRun extends MovieClip
{
private var _vy:Number;
private var _vx:Number;
我在剧本中的播放器
public var _player:player;
public var _boundary:Boundary;
public var _rp:RG;
我声明看到和边界一样
public var _saw:saw;
public var _jump:Boolean=true;
public function PiggyRun():void
{
_rp.visible=false;
_vx=0;
_vy=0;
_player.gotoAndStop('walking');
stage.focus= stage;
this.addEventListener(Event.ENTER_FRAME,enterFrameHandler);
stage.addEventListener(KeyboardEvent.KEY_DOWN, kDHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, kUHandler);
}
private function enterFrameHandler(e:Event):void
{
我增加了 x 因为它是一个正在运行的游戏
_vy+=2;
_vx+=.5;
if(_vx>10)
{
_vx=10
}
_player.x+=_vx;
_player.y+=_vy;
borders();
stageFocus();
sawblade();
}
按下时的控件
private function kDHandler(e:KeyboardEvent):void
{
switch(e.keyCode)
{
case 38:
if(_jump){
_jump=false;
_vy=-20;
}
break;
default:
}
}
我删除了这个函数的内容
private function kUHandler(e:KeyboardEvent):void
{
switch(e.keyCode)
{
}
}
private function borders():void
{
if(_vy > 0)
{
if (_player.y>stage.stageHeight)
{
_player.x=_rp.x;
_player.y=_rp.y;
_boundary.x=0;
_boundary.y=0;
_saw.x=0;
_saw.y=0;
_vy=0;
_vx=0;
}else{
var border:Boolean=false;
if(_boundary.hitTestPoint(_player.x,_player.y,true))
{
border=true;
}
if (border)
{
while(border)
{
_player.y-=0.05;
_jump=true;
border=false;
if(_boundary.hitTestPoint(_player.x,_player.y,true))
{
border=true;
}
}
_vy=0;
}
}
}
}
我把这个函数放在哪里,如果玩家击中锯片,它会重生回到 _rp 的位置,但我很难过 2 个电影剪辑不会相遇,因为即使我强行将 _saw 和它放在一起,它们也会同时移动,这个函数不起作用
private function sawblade():void
{
if(_vy > 0)
{
if (_player.y>stage.stageHeight)
{
_player.x=_rp.x;
_player.y=_rp.y;
_boundary.x=0;
_boundary.y=0;
_saw.x=0;
_saw.y=0;
_vy=0;
_vx=0;
}else{
var sawn:Boolean=false;
if(_saw.hitTestPoint(_player.x,_player.y,true))
{
sawn=true;
}
if (sawn)
{
while(sawn)
{
_player.x=_rp.x;
_player.y=_rp.y;
_boundary.x=0;
_boundary.y=0;
_saw.x=0;
_saw.y=0;
_vy=0;
_vx=0;
_jump=true;
sawn=false;
if(_saw.hitTestPoint(_player.x,_player.y,true))
{
sawn=true;
}
}
_vy=0;
}
}
}
}
private function stageFocus():void
{
_boundary.x+=(stage.stageWidth * 0.5)-_player.x;
_player.x=stage.stageWidth*0.5;
_saw.x=5;
}
}