AS3。如何建立玩家进行实时游戏? [英] AS3. How to set-up players for real-time game?

查看:209
本文介绍了AS3。如何建立玩家进行实时游戏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建Flash格斗游戏1VS1。

I'm creating flash fighting game 1vs1.

下面是英雄(本地播放器)和敌人(远程播放器)。我需要怎么设置他们正确的连接到​​舞台后,他们将成功地催生?

Here is Hero (local-player) and Enemy (remote-player). How I need to setup them correctly that after connection to arena they will be spawned successfully?

我的意思是,如果玩家1连接到赛场上,他应该被声明为英雄(本地播放器)和他的球员2应该像敌人(远程播放器)。

I mean if player 1 connects to arena he should be declared as Hero (local-player) and for him player 2 should look like Enemy (remote-player).

同为玩家2.他应该被声明为英雄(本地播放器)和他的球员1应该像敌人(远程播放器)。

The same for player 2. He should be declared as Hero (local-player) and for him player 1 should look like Enemy (remote-player).

下面有2个字符的模板可供选择,这里code:

Here are 2 character's templates to choose and here is code:

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);
     }

所以英雄加入到阶段(这是本地的玩家)。

So Hero added to stage (It is local-player).

这是我的敌人宣告:

public var Enemy:Priesas = new Priesas; //Priesas is instance name of Enemy

所以,按照我的理解,我不需要用的addChild(敌人); ,因为将仅增加了模板,如何添加远程玩家英雄(从其他电脑),将被宣布为敌人?或者类似的东西。

So as I understand I don't need to use addChild(Enemy); because will be added just template, how to add remote-player Hero (from other computer) that will be declared as Enemy? Or something like that.

这个游戏创造的Facebook。为所需要AppWarp?感谢您的回答。

This game is creating for Facebook. For that is needed AppWarp? Thank you for answers.

推荐答案

是的,你需要AppWarp连接两个球员,并在它们之间交换消息。这似乎类似于AppWarp的样品之一(笑脸空间射击)。你是否已经探讨了样品和文档?

Yes, you would need AppWarp to connect the two players and to exchange messages between them. This seems similar to one of the samples of AppWarp (smiley space shooter). Have you already explored the samples and documentation?

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

这篇关于AS3。如何建立玩家进行实时游戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆