private void benchmarkComplete() { mStarted = false; mStartButton.visible = true; var fps = 60; Debug.Log("Benchmark complete!"); Debug.Log("FPS: " + fps); Debug.Log("Number of objects: " + mContainer.numChildren); var resultString = String.Format("Result:\n{0} objects\nwith {1} fps", mContainer.numChildren, fps); mResultText = new BitmapTextField(); mResultText.width = 480f; mResultText.height = 400f; mResultText.textFormat = Game.textFormat; mResultText.text = resultString; mResultText.x = 320f - mResultText.width / 2f; mResultText.y = 480f - mResultText.height / 2f; addChild(mResultText); mContainer.removeAllChildren(); //System.pauseForGCIfCollectionImminent(); }
public TouchScene() { var description = "[use Ctrl/Cmd & Shift to simulate multi-touch]"; var infoText = new BitmapTextField(); infoText.width = 600f; infoText.height = 50f; infoText.textFormat = Game.textFormat; infoText.text = description; infoText.x = infoText.y = 20; addChild(infoText); // to find out how to react to touch events have a look at the TouchSheet class! // It's part of the demo. sheet = new Image(Game.assets.getTexture("starling_sheet")); sheet.x = 360f - sheet.width * 0.5f; sheet.y = 440f - sheet.height * 0.5f; sheet.rotation = 10f; addChild(sheet); addEventListener(CEvent.ADDED_TO_STAGE, onAddedToStage); addEventListener(CEvent.REMOVED_FROM_STAGE, onRemovedFromStage); }
public BlendModeScene() { mBlendModes = new List <int>(); mBlendModes.Add(BlendMode.ADD); mBlendModes.Add(BlendMode.NORMAL); mButton = new Button(new Image(Game.assets.getTexture("button_normal")), "Switch Mode", null, Game.textFormat); mButton.x = 320f - mButton.width / 2f; mButton.y = 30f; mButton.addEventListener(Button.BUTTON_CLICKED, onButtonTriggered); addChild(mButton); mImage = new Image(Game.assets.getTexture("starling_rocket")); mImage.x = 320f - mImage.width / 2f; mImage.y = 340; addChild(mImage); mInfoText = new BitmapTextField(); mInfoText.width = 600; mInfoText.height = 32; mInfoText.textFormat = Game.textFormat; mInfoText.x = 20; mInfoText.y = 660; addChild(mInfoText); }
void Start ( ) { BMFontReader.registerFonts( bmFonts ); // Font linkage from swf using font name & size mapping stage.addChild( new MovieClip("uniSWF/Examples/Extra examples/BMFont reader/swf/bmfonttest.swf:Font") ); // Add Text to stage TextFormat format = new TextFormat(); format.font = "Times Bold"; format.color = Color.green; format.size = 64; BitmapTextField txt = new BitmapTextField( ); txt.width = 500; txt.height = 200; txt.textFormat = format; txt.text = "BMText set from code"; txt.y = 100; txt.x = 10; txt.type = TextFieldType.INPUT; txt.addCharColor( 7, 9, Color.cyan ); txt.addCharColor( 16, 19, Color.red ); txt.appendText( ", Appended text" ); stage.addChild( txt ); }
private void init() { int offset = 20; //int ttFontSize = 38; var tf = Game.textFormat; tf.fontClassName = null; var colorTF = new BitmapTextField(); colorTF.width = 600f; colorTF.height = 160f; colorTF.textFormat = Game.textFormat; colorTF.text = "TextFields can have a border and a color. They can be aligned in different ways, ..."; //colorTF.textFormat.size = ttFontSize; //colorTF.textFormat.color = 0x333399.hexToColor(); colorTF.multiline = true; colorTF.x = colorTF.y = offset; addChild(colorTF); var leftTF = new BitmapTextField(); leftTF.width = 290f; leftTF.height = 160f; leftTF.textFormat = Game.textFormat; leftTF.text = "... e.g.\ntop-left ..."; leftTF.x = offset; //leftTF.textFormat.size = ttFontSize; //leftTF.textFormat.color = 0x993333.hexToColor(); leftTF.multiline = true; leftTF.y = colorTF.y + colorTF.height + offset; addChild(leftTF); var rightTF = new BitmapTextField(); rightTF.width = 290f; rightTF.height = 160f; rightTF.textFormat = Game.textFormat; rightTF.text = "... or\nbottom right ..."; rightTF.x = 2 * offset + leftTF.width; rightTF.y = leftTF.y; //rightTF.color = 0x228822; rightTF.multiline = true; addChild(rightTF); var fontTF = new BitmapTextField(); fontTF.width = 600f; fontTF.height = 160f; fontTF.textFormat = Game.textFormat; fontTF.text = "... or centered. Embedded fonts are detected automatically."; fontTF.x = offset; fontTF.y = leftTF.y + leftTF.height + offset; fontTF.multiline = true; addChild(fontTF); }
public MaskScene() { mContents = new Sprite(); addChild(mContents); var stageWidth = 640f; var stageHeight = 960f; var touchQuad = new Quad(stageWidth, stageHeight, Color.black); touchQuad.alpha = 0.01f; // used to get touch events addChildAt(touchQuad, 0); var image = new Image(Game.assets.getTexture("flight_00")); image.x = (stageWidth * 0.5f) - (image.width * 0.75f); image.y = 80f; mContents.addChild(image); var scissorText = new BitmapTextField(); scissorText.width = 512f; scissorText.height = 256f; scissorText.multiline = true; scissorText.textFormat = Game.textFormat; scissorText.text = "Move the mouse (or a finger) over the screen to move the clipping rectangle."; scissorText.x = (stageWidth - scissorText.width) * 0.5f; scissorText.y = 480f; mContents.addChild(scissorText); var maskText = new BitmapTextField(); maskText.width = 512f; maskText.height = 256f; maskText.multiline = true; maskText.textFormat = Game.textFormat; maskText.text = "Currently, Starling supports only stage-aligned clipping; more complex masks " + "will be supported in future versions."; maskText.x = scissorText.x; maskText.y = 580; mContents.addChild(maskText); var scissorRect = new Rect(0f, 0f, 300f, 300f); scissorRect.x = (stageWidth - scissorRect.width) / 2f; scissorRect.y = (stageHeight - scissorRect.height) / 2f + 5f; mContents.clipRect = scissorRect; mClipQuad = new Quad(scissorRect.width, scissorRect.height, 0xff0000.hexToColor()); mClipQuad.x = scissorRect.x; mClipQuad.y = scissorRect.y; mClipQuad.alpha = 0.1f; addChild(mClipQuad); addEventListener(MouseEvent.MOUSE_MOVE, onTouch); }
private void init() { int offset = 20; //int ttFontSize = 38; var tf = Game.textFormat; tf.fontClassName = null; var colorTF = new BitmapTextField(); colorTF.width = 600f; colorTF.height = 160f; colorTF.textFormat = Game.textFormat; colorTF.text = "TextFields can have a border and a color. They can be aligned in different ways, ..."; //colorTF.textFormat.size = ttFontSize; //colorTF.textFormat.color = 0x333399.hexToColor(); colorTF.multiline = true; colorTF.x = colorTF.y = offset; addChild(colorTF); var leftTF = new BitmapTextField(); leftTF.width = 290f; leftTF.height = 160f; leftTF.textFormat = Game.textFormat; leftTF.text = "... e.g.\ntop-left ..."; leftTF.x = offset; //leftTF.textFormat.size = ttFontSize; //leftTF.textFormat.color = 0x993333.hexToColor(); leftTF.multiline = true; leftTF.y = colorTF.y + colorTF.height + offset; addChild(leftTF); var rightTF = new BitmapTextField(); rightTF.width = 290f; rightTF.height = 160f; rightTF.textFormat = Game.textFormat; rightTF.text = "... or\nbottom right ..."; rightTF.x = 2*offset + leftTF.width; rightTF.y = leftTF.y; //rightTF.color = 0x228822; rightTF.multiline = true; addChild(rightTF); var fontTF = new BitmapTextField(); fontTF.width = 600f; fontTF.height = 160f; fontTF.textFormat = Game.textFormat; fontTF.text = "... or centered. Embedded fonts are detected automatically."; fontTF.x = offset; fontTF.y = leftTF.y + leftTF.height + offset; fontTF.multiline = true; addChild(fontTF); }
//private TextField txt; public MainMenu() { logo = new Image(Game.assets.getTexture("logo")); addChild(logo); var scenesToCreate = new List <String> { "Textures", "Multitouch", "TextFields", "Animations", //"Custom hit-test", "Movie Clip", //"Filters", "Blend Modes", //"Render Texture", "Clipping", "Benchmark" }; var buttonTexture = Game.assets.getTexture("button_medium"); var count = 0; foreach (var sceneToCreate in scenesToCreate) { var sceneTitle = sceneToCreate; var button = new Button(new Image(buttonTexture), sceneTitle, null, Game.textFormat); button.x = count % 2 == 0 ? 56 : 334; button.y = 310 + (count / 2) * 92; button.name = sceneTitle; button.addEventListener(Button.BUTTON_CLICKED, onButtonTriggered); addChild(button); if (scenesToCreate.Count % 2 != 0 && count % 2 == 1) { button.y += 48; } ++count; } BitmapTextField bmpTxt = new BitmapTextField( ); bmpTxt.width = 500; bmpTxt.height = 200; bmpTxt.textFormat = Game.textFormat; bmpTxt.text = "uniStarling Demo App"; bmpTxt.y = 900; bmpTxt.x = 56; addChild(bmpTxt); }
void Start ( ) { // // Alter existing font // Add root with single textfield mc = new MovieClip( "uniSWF/Examples/Extra examples/ProgramaticTextFields/swf/programaticText.swf:Root" ) ; stage.addChild( mc ); // Ensure player is not changing textfields on timeline mc.stop(); // Get textfield txt = mc.getChildByName<TextField>( "txt" ); // Get format TextFormat format = txt.textFormat; // Set new format format.fontClassName = null; // Clear class for bitmap fonts as this points to the exact font_size_filters assets format.size = 30; // Set format txt.textFormat = format; // // Add new textfield using font and size ( must be exported ) format = new TextFormat(); format.font = "Times Bold"; format.color = Color.green; format.size = 64; BitmapTextField bmpTxt = new BitmapTextField( ); bmpTxt.width = 500; bmpTxt.height = 200; bmpTxt.textFormat = format; bmpTxt.text = "Text set from code"; bmpTxt.y = 100; bmpTxt.x = 10; bmpTxt.type = TextFieldType.INPUT; bmpTxt.addCharColor( 5, 8, Color.cyan ); bmpTxt.addCharColor( 14, 17, Color.red ); bmpTxt.appendText( ", Appended text" ); stage.addChild( bmpTxt ); }
//private TextField txt; public MainMenu() { logo = new Image( Game.assets.getTexture("logo") ); addChild(logo); var scenesToCreate = new List<String>{ "Textures", "Multitouch", "TextFields", "Animations", //"Custom hit-test", "Movie Clip", //"Filters", "Blend Modes", //"Render Texture", "Clipping", "Benchmark" }; var buttonTexture = Game.assets.getTexture("button_medium"); var count = 0; foreach (var sceneToCreate in scenesToCreate) { var sceneTitle = sceneToCreate; var button = new Button( new Image(buttonTexture), sceneTitle, null, Game.textFormat); button.x = count % 2 == 0 ? 56 : 334; button.y = 310 + (count / 2) * 92; button.name = sceneTitle; button.addEventListener(Button.BUTTON_CLICKED, onButtonTriggered); addChild(button); if (scenesToCreate.Count % 2 != 0 && count % 2 == 1) button.y += 48; ++count; } BitmapTextField bmpTxt = new BitmapTextField( ); bmpTxt.width = 500; bmpTxt.height = 200; bmpTxt.textFormat = Game.textFormat; bmpTxt.text = "uniStarling Demo App"; bmpTxt.y = 900; bmpTxt.x = 56; addChild( bmpTxt ); }
private void onStartButtonTriggered(CEvent e) { Debug.Log("Starting benchmark"); mStartButton.visible = false; mStarted = true; mFailCount = 0; mWaitFrames = 2; mFrameCount = 0; if (mResultText != null) { removeChild(mResultText); mResultText = null; } addTestObjects(); }
private void createTextField() { if (mTextField == null) { //mTextField = new TextField(mTextBounds.width, mTextBounds.height, ""); mTextField = new BitmapTextField(); mTextField.textFormat = mTextFormat; /*mTextField.vAlign = VAlign.CENTER; * mTextField.hAlign = HAlign.CENTER; * mTextField.touchable = false; * mTextField.autoScale = true;*/ mContents.addChild(mTextField); } mTextField.width = mTextBounds.width; mTextField.height = mTextFormat.size; mTextField.x = mTextBounds.x; mTextField.y = (mTextBounds.height * 0.5f) - (mTextField.height * 0.75f); }
public AnimationScene() : base() { mTransitions = new List<String>(); mTransitions.Add(Transitions.LINEAR); mTransitions.Add(Transitions.EASE_IN_OUT); mTransitions.Add(Transitions.EASE_OUT_BACK); mTransitions.Add(Transitions.EASE_OUT_BOUNCE); mTransitions.Add(Transitions.EASE_OUT_ELASTIC); var buttonTexture = Game.assets.getTexture("button_normal"); // create a button that starts the tween mStartButton = new Button(new Image(buttonTexture), "Start animation", null, Game.textFormat); mStartButton.addEventListener(Button.BUTTON_CLICKED, onStartButtonTriggered); mStartButton.x = 320f - mStartButton.width / 2f; mStartButton.y = 40f; addChild(mStartButton); // this button will show you how to call a method with a delay mDelayButton = new Button(new Image(buttonTexture), "Delayed call", null, Game.textFormat); mDelayButton.addEventListener(Button.BUTTON_CLICKED, onDelayButtonTriggered); mDelayButton.x = mStartButton.x; mDelayButton.y = mStartButton.y + 80f; addChild(mDelayButton); // the Starling will be tweened mEgg = new Image(Game.assets.getTexture("starling_front")); addChild(mEgg); resetEgg(); mTransitionLabel = new BitmapTextField(); mTransitionLabel.width = 640f; mTransitionLabel.height = 30f; mTransitionLabel.textFormat = Game.textFormat; mTransitionLabel.y = mDelayButton.y + 80f; mTransitionLabel.alpha = 0.0f; // invisible, will be shown later addChild(mTransitionLabel); }
public AnimationScene() : base() { mTransitions = new List <String>(); mTransitions.Add(Transitions.LINEAR); mTransitions.Add(Transitions.EASE_IN_OUT); mTransitions.Add(Transitions.EASE_OUT_BACK); mTransitions.Add(Transitions.EASE_OUT_BOUNCE); mTransitions.Add(Transitions.EASE_OUT_ELASTIC); var buttonTexture = Game.assets.getTexture("button_normal"); // create a button that starts the tween mStartButton = new Button(new Image(buttonTexture), "Start animation", null, Game.textFormat); mStartButton.addEventListener(Button.BUTTON_CLICKED, onStartButtonTriggered); mStartButton.x = 320f - mStartButton.width / 2f; mStartButton.y = 40f; addChild(mStartButton); // this button will show you how to call a method with a delay mDelayButton = new Button(new Image(buttonTexture), "Delayed call", null, Game.textFormat); mDelayButton.addEventListener(Button.BUTTON_CLICKED, onDelayButtonTriggered); mDelayButton.x = mStartButton.x; mDelayButton.y = mStartButton.y + 80f; addChild(mDelayButton); // the Starling will be tweened mEgg = new Image(Game.assets.getTexture("starling_front")); addChild(mEgg); resetEgg(); mTransitionLabel = new BitmapTextField(); mTransitionLabel.width = 640f; mTransitionLabel.height = 30f; mTransitionLabel.textFormat = Game.textFormat; mTransitionLabel.y = mDelayButton.y + 80f; mTransitionLabel.alpha = 0.0f; // invisible, will be shown later addChild(mTransitionLabel); }
public TouchScene() { var description = "[use Ctrl/Cmd & Shift to simulate multi-touch]"; var infoText = new BitmapTextField(); infoText.width = 600f; infoText.height = 50f; infoText.textFormat = Game.textFormat; infoText.text = description; infoText.x = infoText.y = 20; addChild(infoText); // to find out how to react to touch events have a look at the TouchSheet class! // It's part of the demo. sheet = new Image( Game.assets.getTexture("starling_sheet") ); sheet.x = 360f - sheet.width * 0.5f; sheet.y = 440f - sheet.height * 0.5f; sheet.rotation = 10f; addChild(sheet); addEventListener(CEvent.ADDED_TO_STAGE, onAddedToStage); addEventListener(CEvent.REMOVED_FROM_STAGE, onRemovedFromStage); }
private void onStartButtonTriggered( CEvent e ) { Debug.Log("Starting benchmark"); mStartButton.visible = false; mStarted = true; mFailCount = 0; mWaitFrames = 2; mFrameCount = 0; if (mResultText != null) { removeChild(mResultText); mResultText = null; } addTestObjects(); }
private void createTextField() { if (mTextField == null) { //mTextField = new TextField(mTextBounds.width, mTextBounds.height, ""); mTextField = new BitmapTextField(); mTextField.textFormat = mTextFormat; /*mTextField.vAlign = VAlign.CENTER; mTextField.hAlign = HAlign.CENTER; mTextField.touchable = false; mTextField.autoScale = true;*/ mContents.addChild(mTextField); } mTextField.width = mTextBounds.width; mTextField.height = mTextFormat.size; mTextField.x = mTextBounds.x; mTextField.y = (mTextBounds.height * 0.5f) - (mTextField.height * 0.75f); }