我正在创建 Flash 格斗游戏 1vs1。
这里是英雄(本地玩家)和敌人(远程玩家)。我需要如何正确设置它们,以便在连接到竞技场后成功生成它们?
我的意思是,如果玩家 1 连接到竞技场,他应该被声明为英雄(本地玩家),而对于他来说,玩家 2 应该看起来像敌人(远程玩家)。
玩家 2 也是如此。他应该被声明为 Hero(本地玩家),而对于他来说,玩家 1 应该看起来像 Enemy(远程玩家)。
这里有 2 个角色的模板可供选择,这里是代码:
public function selectHero(what:int):void {
// this is called with correct "what", design yourself. I use array index
var whatHero:Class = heroes[what]; // get selected hero symbol
if (Hero && Hero.parent) Hero.parent.removeChild(Hero);
// clean up previous hero. Drop listeners here, if any
Hero = new whatHero(); // get new hero
// process as usual, don't forget to "addChild(Hero)" somewhere
create_hero();
}
function choosePlayer(event:MouseEvent):void {
selectHero(0); // here choose first template
start(event);
}
function create_hero()
{
addChild(Hero);
}
所以英雄加入了舞台(它是本地玩家)。
这就是我声明敌人的方式:
public var Enemy:Priesas = new Priesas; //Priesas is instance name of Enemy
因此,据我所知,我不需要使用addChild(Enemy);
,因为只会添加模板,如何添加将被声明为敌人的远程玩家英雄(来自其他计算机)?或类似的东西。
这个游戏是为 Facebook 创作的。为此需要 AppWarp?谢谢你的回答。