我正在创建Flash Grught Game 1vs1。
这是英雄(本地玩家)和敌人(远程玩家)。我需要正确设置它们,与竞技场连接后,它们将成功产生?
我的意思是,如果球员1连接到竞技场,他应该被宣布为英雄(本地玩家),对他来说,球员2应该看起来像敌人(远程玩家)。
对于玩家2的
,他应该被称为英雄(本地玩家),对他来说,球员1应该看起来像敌人(远程玩家)。
这是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吗?谢谢您的答案。
是的,您需要AppWarp来连接两个播放器并在它们之间交换消息。这似乎类似于AppWarp(笑脸射击游戏)的样本之一。您是否已经探索了样本和文档?
http://appwarp.shephertz.com/game-development-center/actionscript3-game-developers-home/