Package | com.presenttechnologies.phunegaming.client.platform.theme.controls |
Class | public class PhuneGameHeader |
Inheritance | PhuneGameHeader ![]() |
The PhuneGameHeader is used on all games to appear the two players, that are playing, on the top of screen game.
Configure PhuneGameHeaderThe PhuneGameHeader should be passed to GameRoot constructor. You can customize your PhuneGameHeader passing your own params that fits better to your game. On GameRoot constructor you also have to pass how much pixels of height your PhuneGameHeader will occupied, including top margin you wanna give to your PhuneGameHeader. Is from this size that PhuneGameHeader will be positionated on the screen (PhuneGameHeader + Top Margin).
public function GameRootImpl() { const headerArea:int = UtilService.scaleUnit(225) // Scaled const gameHeader:PhuneGameHeader = new PhuneGameHeader(); super(gameHeader, headerArea); }
Note: Make sure that all your params are scaled first.
Using fontsWhen you have to use some Bitmap Fonts, you usually have to register it using Font.registerFont(FONT_SOURCE), but here you don't have to care about it, and you shouldn't, to avoid some memory leaks. Instead, pass the Font source classes, on the fourth param of the PhuneGameHeader. You can pass it on Array of Fonts or just one Font class, it's your choice.
Get some fonts here.
ExampleThere is a complete example used on one of our games.
[Embed(source = "../../../../../assets/game/fonts/PetMe128.ttf", fontName = "Pet Me 128", mimeType = "application/x-font", embedAsCFF="false")] public static var FONT_SOURCE_128:Class; public static var FONT_128:Font = new FONT_SOURCE_128(); [Embed(source = "../../../../../assets/game/fonts/PetMe64.ttf", fontName = "Pet Me 64", mimeType = "application/x-font", embedAsCFF="false")] public static var FONT_SOURCE_64:Class; public static var FONT_64:Font = new FONT_SOURCE_64(); public function GameRootImpl() { const headerArea:int = UtilService.scaleUnit(225); const tfNickname:TextFormat = new TextFormat(Assets.FONT_128.fontName, UtilService.scaleUnit(16), 0xFFFFFF); tfNickname.leading = 0; tfNickname.letterSpacing = UtilService.scaleUnitToNumber(0.1); const tfRank:TextFormat = new TextFormat(Assets.FONT_128.fontName, UtilService.scaleUnit(13), 0x63FFFF); tfRank.leading = UtilService.scaleUnit(20); const tfCounter:TextFormat = new TextFormat(Assets.FONT_128.fontName, UtilService.scaleUnit(28)); tfCounter.leading = 0; const gameHeader:PhuneGameHeader = new PhuneGameHeader(tfNickname, tfRank, tfCounter,[FONT_SOURCE_128, FONT_SOURCE_64], 0xFFFF00,0x000000); gameHeader.touchable = false; gameHeader.gapNickRank = UtilService.scaleUnit(10); gameHeader.delayChangeAvatar = 1; //Seconds gameHeader.showWithAnim = false; super(gameHeader, headerArea); }
See also
Property | Defined By | ||
---|---|---|---|
avatarRadius : int
Radius of avatar. | PhuneGameHeader | ||
delayChangeAvatar : Number
Delay in seconds to change player playing. | PhuneGameHeader | ||
gapNickRank : int
Gap value between Nickname and Ranking (First and second line)
| PhuneGameHeader | ||
marginSides : int
Margin of avatars on left and right side. | PhuneGameHeader | ||
showWithAnim : Boolean
If there is any animation on changing player playing. | PhuneGameHeader |
Method | Defined By | ||
---|---|---|---|
PhuneGameHeader(nicknameTextFormat:* = null, rankingTextFormat:* = null, timeCounterTextFormat:* = null, fontClass:* = null, colorWinner:Number, avatarBorderColor:Number, withAnim:Boolean = true)
You can customize your PhuneGameHeader by placing your custom preferences on constructor. | PhuneGameHeader |
Constant | Defined By | ||
---|---|---|---|
DEFAULT_AVATAR_BORDER : Number = 0x666666 [static] | PhuneGameHeader | ||
DEFAULT_NICKNAME_COLOR : Number = 0x336633 [static] | PhuneGameHeader | ||
DEFAULT_RANKING_COLOR : Number = 0x514F4B [static] | PhuneGameHeader | ||
DEFAULT_WINNER_COLOR : Number = 0xF09600 [static] | PhuneGameHeader |
avatarRadius | property |
avatarRadius:int
Radius of avatar.
public function get avatarRadius():int
public function set avatarRadius(value:int):void
delayChangeAvatar | property |
delayChangeAvatar:Number
Delay in seconds to change player playing. This delay is used when you want to do something after some Move and before changing to the next player playing.
public function get delayChangeAvatar():Number
public function set delayChangeAvatar(value:Number):void
gapNickRank | property |
gapNickRank:int
Gap value between Nickname and Ranking (First and second line)
public function get gapNickRank():int
public function set gapNickRank(value:int):void
marginSides | property |
marginSides:int
Margin of avatars on left and right side.
public function get marginSides():int
public function set marginSides(value:int):void
showWithAnim | property |
showWithAnim:Boolean
If there is any animation on changing player playing.
public function get showWithAnim():Boolean
public function set showWithAnim(value:Boolean):void
PhuneGameHeader | () | Constructor |
public function PhuneGameHeader(nicknameTextFormat:* = null, rankingTextFormat:* = null, timeCounterTextFormat:* = null, fontClass:* = null, colorWinner:Number, avatarBorderColor:Number, withAnim:Boolean = true)
You can customize your PhuneGameHeader by placing your custom preferences on constructor. You can also create the PhuneGameHeader by default, letting the platform use the default values.
ParametersnicknameTextFormat:* (default = null ) — TextFormat for nickname (this is the same for both players)
| |
rankingTextFormat:* (default = null ) — TextFormat for ranking (this is the same for both players)
| |
timeCounterTextFormat:* (default = null ) — TextFormat for time counter (this is the same for both players)
| |
fontClass:* (default = null ) — You can place an array of Font classes, or just one class. You don't need to (and you shouldn't) register the fonts on your side, platform will care about it for you.
| |
colorWinner:Number (default = NaN ) — Color that will be used on winner label when the match is finished. | |
avatarBorderColor:Number (default = NaN ) — Which color will be used on avatar border | |
withAnim:Boolean (default = true ) — If the change players will be done with animations
|
DEFAULT_AVATAR_BORDER | Constant |
public static const DEFAULT_AVATAR_BORDER:Number = 0x666666
DEFAULT_NICKNAME_COLOR | Constant |
public static const DEFAULT_NICKNAME_COLOR:Number = 0x336633
DEFAULT_RANKING_COLOR | Constant |
public static const DEFAULT_RANKING_COLOR:Number = 0x514F4B
DEFAULT_WINNER_COLOR | Constant |
public static const DEFAULT_WINNER_COLOR:Number = 0xF09600