0

我正在创建 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?谢谢你的回答。

4

1 回答 1

0

是的,您需要 AppWarp 来连接两个播放器并在它们之间交换消息。这似乎类似于 AppWarp(笑脸太空射击游戏)的样本之一。您是否已经浏览过示例和文档?

http://appwarp.shephertz.com/game-development-center/actionscript3-game-developers-home/

于 2014-01-29T05:34:01.417 回答