我有一个班级,玩家,这是一个简单的人物。我在我的类Main中将它声明为p1,然后尝试将其定义为我的Main函数中的新播放器,但后来我得到错误,说p1未定义且无法使用。
public class Main extends MovieClip
{
var p1:player;
var p1Controls:buttonPage;
var p2:player;
var p2Controls:buttonPage;
function Main ();
{
p1 = new player;
addChild(p1);
p1.x = 100;
p1.y = stage.height/2;
p1Controls = new buttonPage;
addChild(p1Controls);
p1Controls.p1Atk.addEventListener(MouseEvent.CLICK, p1AtkF);
p1Controls.p1Buff.addEventListener(MouseEvent.CLICK, p1BuffF);
p1Controls.p1SP.addEventListener(MouseEvent.CLICK, p1SPF);
p2 = new player;
addChild(p2);
p2.x = stage.width-100;
p2.y = p1.y;
p2Controls = new buttonPage;
}