Allow a game to delay its start until all of its players are actually ready
rather than assuming that as soon as they construct the EZGameControl, they're ready to play. That's not totally unreasonable, but with this new explicit mechanism, games can also "rematch" (or just replay if it's single player) by having all clients call playerReady() again after the game has ended. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@328 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -107,7 +107,6 @@ import flash.display.DisplayObject;
|
||||
*/
|
||||
[Event(name="UserChat", type="com.threerings.ezgame.UserChatEvent")]
|
||||
|
||||
|
||||
/**
|
||||
* The single point of control for each client in your multiplayer EZGame.
|
||||
*
|
||||
@@ -117,12 +116,17 @@ public class EZGameControl extends BaseControl
|
||||
{
|
||||
/**
|
||||
* Create an EZGameControl object using some display object currently on the hierarchy.
|
||||
*
|
||||
* @param disp the display object that is the game's UI.
|
||||
* @param autoReady if true, the game will automatically be started when initialization is
|
||||
* complete, if false, the game will not start until all clients call {@link #playerReady}.
|
||||
*/
|
||||
public function EZGameControl (disp :DisplayObject)
|
||||
public function EZGameControl (disp :DisplayObject, autoReady :Boolean)
|
||||
{
|
||||
var event :DynEvent = new DynEvent();
|
||||
event.userProps = new Object();
|
||||
populateProperties(event.userProps);
|
||||
event.userProps["autoReady_v1"] = autoReady;
|
||||
disp.root.loaderInfo.sharedEvents.dispatchEvent(event);
|
||||
if ("ezProps" in event) {
|
||||
setEZProps(event.ezProps);
|
||||
@@ -363,6 +367,16 @@ public class EZGameControl extends BaseControl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the game was not configured to auto-start, all clients must call this function to let the
|
||||
* server know that they are ready, at which point the game will be started. Once a game is
|
||||
* over, all clients can call this function again to start a new game.
|
||||
*/
|
||||
public function playerReady () :void
|
||||
{
|
||||
callEZCode("playerReady_v1");
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests a set of random letters from the dictionary service. The letters will arrive in a
|
||||
* separate message with the specified key, as an array of strings.
|
||||
|
||||
Reference in New Issue
Block a user