public HelloWorldLayer() : base(new CCColor4B (0xaa, 0xaa, 0xaa, 0xff)) { var size = CCDirector.SharedDirector.WinSize; var label = new CCLabelTTF ("Hello Xamarin.Mac", "Marker Felt", 32) { Position = new PointF (size.Width/2,size.Height/2), }; Add (label); }
public bool InitWithString(string value, SEL_MenuHandler selector) { //CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0"); m_strFontName = _fontName; m_uFontSize = _fontSize; CCLabelTTF label = new CCLabelTTF(value, m_strFontName, m_uFontSize); base.InitWithLabel(label, selector); return true; }
public GameStartLayer() { TouchEnabled = true; statusLabel = new CCLabelTTF(status, "MarkerFelt", 22) { Position = CCDirector.SharedDirector.WinSize.Center, Color = new CCColor3B(XNA.Color.Yellow) }; AddChild(statusLabel); Color = new CCColor3B(XNA.Color.ForestGreen); Opacity = 255; }
/// <summary> /// AddTitleMenu only text /// </summary> /// <param name="p_Layer">current CCLayer</param> /// <param name="p_TitleText">show text</param> /// <param name="y">current y</param> public static void AddTitleMenu(CCLayer p_Layer, String p_TitleText, ref float y) { CCLabelTTF label = CCLabelTTF.labelWithString(p_TitleText, "ChineseTitle", 28); label.Color = new ccColor3B(Color.White); CCMenuItemLabel tab = CCMenuItemLabel.itemWithLabel(label); CCMenu menu = CCMenu.menuWithItems(tab); menu.position = new CCPoint(CCDirector.sharedDirector().displaySizeInPixels.width / 2, y); //menu.position.y = p_CurrPoint.y; y -= tab.contentSize.height + Blank; p_Layer.addChild(menu); }
public IntroLayer() { // create and initialize a Label var label = new CCLabelTTF("Hello Cocos2D-XNA", "MarkerFelt", 22); // position the label on the center of the screen label.Position = CCDirector.SharedDirector.WinSize.Center; // add the label as a child to this Layer AddChild(label); // setup our color for the background Color = new CCColor3B(Microsoft.Xna.Framework.Color.Blue); Opacity = 255; }
public override void OnEnter() { base.OnEnter(); CCSprite bg = new CCSprite("Images/background3"); AddChild(bg, 0, EffectAdvanceScene.kTagBackground); bg.Position = CCVisibleRect.Center; grossini = new CCSprite("Images/grossinis_sister2"); bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1); grossini.Position = new CCPoint(CCVisibleRect.Left.X + CCVisibleRect.VisibleRect.Size.Width / 3, CCVisibleRect.Center.Y); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever((CCActionInterval)(new CCSequence(sc, sc_back)))); tamara = new CCSprite("Images/grossinis_sister1"); bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2); tamara.Position = new CCPoint(CCVisibleRect.Left.X + 2 * CCVisibleRect.VisibleRect.Size.Width / 3, CCVisibleRect.Center.Y); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever((CCActionInterval)(new CCSequence(sc2, sc2_back)))); CCLabelTTF label = new CCLabelTTF(title(), "arial", 28); label.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Top.Y - 80); AddChild(label); label.Tag = EffectAdvanceScene.kTagLabel; CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback); CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback); CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = CCPoint.Zero; item1.Position = new CCPoint(CCVisibleRect.Center.X - item2.ContentSize.Width * 2, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); item2.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); item3.Position = new CCPoint(CCVisibleRect.Center.X + item2.ContentSize.Width * 2, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); AddChild(menu, 1); }
public override void onEnter() { base.onEnter(); float x, y; CCSize size = CCDirector.sharedDirector().getWinSize(); x = size.width; y = size.height; //CCMutableArray *array = [UIFont familyNames]; //for( CCString *s in array ) // NSLog( s ); CCLabelTTF label = CCLabelTTF.labelWithString("cocos2d", "Arial", 64); label.position = new CCPoint(x / 2, y / 2); addChild(label); }
public override void OnEnter() { base.OnEnter(); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; //CCMutableArray *array = [UIFont familyNames]; //for( CCString *s in array ) // NSLog( s ); CCLabelTTF label = new CCLabelTTF("cocos2d", "arial", 64); label.Position = new CCPoint(x / 2, y / 2); AddChild(label); }
public override void onEnter() { base.onEnter(); //add the menu item for back to main menu CCLabelTTF label = CCLabelTTF.labelWithString("MainMenu", "Arial", 20); CCMenuItemLabel pMenuItem = CCMenuItemLabel.itemWithLabel(label, this, new SEL_MenuHandler(MainMenuCallback)); CCMenu pMenu = CCMenu.menuWithItems(pMenuItem); CCSize s = CCDirector.sharedDirector().getWinSize(); pMenu.position = new CCPoint(0.0f, 0.0f); pMenuItem.position = new CCPoint(s.width - 50, 25); addChild(pMenu, 1); }
/// <summary> /// add "select image" button /// </summary> private void AddImageButton() { CCMenuItemImage image = CCMenuItemImage.itemFromNormalImage("image/ButtonNormal", "image/ButtonClick", this, AddImageClick); CCLabelTTF text = CCLabelTTF.labelWithString("选择图片", "ChineseContent", 28); text.Color = new ccColor3B(Color.Black); CCMenuItemLabel label = CCMenuItemLabel.itemWithLabel(text); CCMenu menu = CCMenu.menuWithItems(image, label); menu.position = new CCPoint(240, m_CurrPostion.y); addChild(menu); m_CurrPostion.y -= image.contentSize.height; m_CurrPostion.y -= StillWhite; }
public HelloWorldLayer() { TouchEnabled = true; AccelerometerEnabled = true; var s = CCDirector.SharedDirector.WinSize; var label = new CCLabelTTF("Multi touch the screen", "Marker Felt", 36) { Position = new PointF(s.Width / 2, s.Height - 40) }; Add(label, -1); CreateMenu(); }
public override void FinishedLaunching(NSObject notification) { CCDirector director = CCDirector.SharedDirector (); director.View = glView; director.DisplayStats = true; CCScene scene = new CCScene(); CCLabelTTF label = new CCLabelTTF("Hello World", "Marker Felt", 64); SizeF size = director.WinSize (); label.Position = new PointF(size.Width/2, size.Height/2); scene.AddChild(label); director.RunWithScene(scene); }
public override bool Init() { if (base.Init()) { CCSize screenSize = CCDirector.SharedDirector.WinSize; // Add a label in which the button events will be displayed setDisplayValueLabel(new CCLabelTTF("No Event", "Arial", 32)); m_pDisplayValueLabel.AnchorPoint = new CCPoint(0.5f, -1); m_pDisplayValueLabel.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f); AddChild(m_pDisplayValueLabel, 1); // Add the button var backgroundButton = new CCScale9SpriteFile("extensions/button"); var backgroundHighlightedButton = new CCScale9SpriteFile("extensions/buttonHighlighted"); var titleButton = new CCLabelTTF("Touch Me!", "Arial", 30); titleButton.Color = new CCColor3B(159, 168, 176); var controlButton = new CCControlButton(titleButton, backgroundButton); controlButton.SetBackgroundSpriteForState(backgroundHighlightedButton, CCControlState.Highlighted); controlButton.SetTitleColorForState(CCTypes.CCWhite, CCControlState.Highlighted); controlButton.AnchorPoint = new CCPoint(0.5f, 1); controlButton.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f); AddChild(controlButton, 1); // Add the black background var background = new CCScale9SpriteFile("extensions/buttonBackground"); background.ContentSize = new CCSize(300, 170); background.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f); AddChild(background); // Sets up event handlers controlButton.AddTargetWithActionForControlEvent(this, touchDownAction, CCControlEvent.TouchDown); controlButton.AddTargetWithActionForControlEvent(this, touchDragInsideAction, CCControlEvent.TouchDragInside); controlButton.AddTargetWithActionForControlEvent(this, touchDragOutsideAction, CCControlEvent.TouchDragOutside); controlButton.AddTargetWithActionForControlEvent(this, touchDragEnterAction, CCControlEvent.TouchDragEnter); controlButton.AddTargetWithActionForControlEvent(this, touchDragExitAction, CCControlEvent.TouchDragExit); controlButton.AddTargetWithActionForControlEvent(this, touchUpInsideAction, CCControlEvent.TouchUpInside); controlButton.AddTargetWithActionForControlEvent(this, touchUpOutsideAction, CCControlEvent.TouchUpOutside); controlButton.AddTargetWithActionForControlEvent(this, touchCancelAction, CCControlEvent.TouchCancel); return(true); } return(false); }
public GameLevel() { layerInstance = this; // enable touches #if XBOX || OUYA TouchEnabled = false; GamePadEnabled = true; #else TouchEnabled = true; #endif // enable accelerometer AccelerometerEnabled = false; // ask director for the window size var screenSize = CCDirector.SharedDirector.WinSize; // create and initialize a Label var label = new CCLabelTTF("Game Layer", "MarkerFelt", 22); // position the label on the center of the screen label.Position = CCDirector.SharedDirector.WinSize.Center; // add the label as a child to this Layer AddChild(label); menuStartPosition = new CCPoint(70, screenSize.Height - 24); var gameMenuLabel = new CCLabelTTF("Game Menu", "MarkerFelt", 18); var button1 = new CCMenuItemLabel(gameMenuLabel, ShowMenu); MenuButton = new CCMenu(button1); MenuButton.Position = menuStartPosition; AddChild(MenuButton, 10); openWithMenuInsteadOfGame = false; if (GameData.SharedData.FirstRunEver && openWithMenuInsteadOfGame) { CCLog.Log("First run ever"); Schedule(ShowMenuFromSelector, 2f); GameData.SharedData.FirstRunEver = false; } }
public override void OnEnter() { base.OnEnter(); AccelerometerEnabled = true; CCSize s = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF(title(), "Arial", 32); AddChild(label, 1); label.Position = new CCPoint(s.Width / 2, s.Height - 50); m_pBall = new CCSprite("Images/ball"); m_pBall.Position = s.Center; AddChild(m_pBall); }
public LabelTTFTest() { CCSize s = CCDirector.sharedDirector().getWinSize(); // CCLabelBMFont CCLabelTTF left = CCLabelTTF.labelWithString("align left", new CCSize(s.width, 50), CCTextAlignment.CCTextAlignmentLeft, "Arial", 32); CCLabelTTF center = CCLabelTTF.labelWithString("align center", new CCSize(s.width, 50), CCTextAlignment.CCTextAlignmentCenter, "Arial", 32); CCLabelTTF right = CCLabelTTF.labelWithString("align right", new CCSize(s.width, 50), CCTextAlignment.CCTextAlignmentRight, "Arial", 32); left.position = new CCPoint(s.width / 2, 200); center.position = new CCPoint(s.width / 2, 150); right.position = new CCPoint(s.width / 2, 100); addChild(left); addChild(center); addChild(right); }
/** Creates and return a button with a default background and title color. */ public CCControlButton standardButtonWithTitle(string title) { /** Creates and return a button with a default background and title color. */ var backgroundButton = new CCScale9SpriteFile("extensions/button"); var backgroundHighlightedButton = new CCScale9SpriteFile("extensions/buttonHighlighted"); var titleButton = new CCLabelTTF(title, "Arial", 30); titleButton.Color = new CCColor3B(159, 168, 176); var button = new CCControlButton(titleButton, backgroundButton); button.SetBackgroundSpriteForState(backgroundHighlightedButton, CCControlState.Highlighted); button.SetTitleColorForState(CCTypes.CCWhite, CCControlState.Highlighted); return(button); }
public override bool Init() { if (base.Init()) { CCSize size = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF("Layer2", "MarkerFelt", 36); label.Position = new CCPoint(size.Width / 2, size.Height / 2); AddChild(label); AccelerometerEnabled = true; Schedule(switchLayer, 5.0f); return(true); } return(false); }
public override bool init() { if (base.init()) { CCSize size = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString("Layer2", "Marker Felt", 36); label.position = new CCPoint(size.width / 2, size.height / 2); addChild(label); isAccelerometerEnabled = true; schedule(switchLayer, 5.0f); return(true); } return(false); }
/// <summary> /// show word /// </summary> /// <param name="p_Word">word object</param> private void LoadWord(Word p_Word) { m_y -= 10; //Picture CCTexture2D text2d = Media.PictureManager.GetCCTexture2D(p_Word); CCSprite spritepic = CCSprite.spriteWithTexture(text2d); if (PictureWidth < text2d.ContentSizeInPixels.width) { spritepic.scaleX = PictureWidth / text2d.ContentSizeInPixels.width; } if (PictureHeight < text2d.ContentSizeInPixels.height) { spritepic.scaleY = PictureHeight / text2d.ContentSizeInPixels.height; } spritepic.contentSize.width = PictureWidth; spritepic.contentSize.height = PictureHeight; //word name CCLabelTTF chineseText = CCLabelTTF.labelWithString(p_Word.ChineseName, "ChineseContent", 28); CCMenuItemLabel chineseLabel = CCMenuItemLabel.itemWithLabel(chineseText); CCLabelTTF englishText = CCLabelTTF.labelWithString(p_Word.EnglishName, "EnglishContent", 28); CCMenuItemLabel englishLabel = CCMenuItemLabel.itemWithLabel(englishText); //del button CCLabelTTF delText = CCLabelTTF.labelWithString("删除", "ChineseContent", 28); CCMenuItemLabel delbutton = CCMenuItemLabel.itemWithLabel(delText, this, this.DeleteClick); delbutton.userData = p_Word; CCMenu menu = CCMenu.menuWithItems(delbutton); spritepic.position = new CCPoint(80, m_y - spritepic.contentSize.height / 2); chineseLabel.position = new CCPoint(250, m_y - 40); chineseLabel.Color = new ccColor3B(Color.Black); englishLabel.position = new CCPoint(250, m_y - 80); englishLabel.Color = new ccColor3B(Color.Black); menu.position = new CCPoint(430, m_y - 60); delbutton.Color = new ccColor3B(Color.Black); addChild(spritepic); addChild(chineseLabel); addChild(englishLabel); addChild(menu); m_y -= PictureHeight; m_y -= 10; }
public IntroLayer() { // create and initialize a Label var label = new CCLabelTTF("Intro Layer", "MarkerFelt", 22); // position the label on the center of the screen label.Position = CCDirector.SharedDirector.WinSize.Center; // add the label as a child to this Layer AddChild(label); // setup our color for the background Color = new CCColor3B(Microsoft.Xna.Framework.Color.Blue); Opacity = 255; // Wait a little and then transition to the new scene ScheduleOnce(TransitionOut, 2); }
private void updateAlignment() { var blockSize = new CCSize(200, 160); CCSize s = CCDirector.SharedDirector.WinSize; if (m_plabel != null) { m_plabel.RemoveFromParentAndCleanup(true); } m_plabel = new CCLabelTTF(getCurrentAlignment(), "Marker Felt", 32, blockSize, m_eHorizAlign, m_eVertAlign); m_plabel.AnchorPoint = new CCPoint(0, 0); m_plabel.Position = new CCPoint((s.Width - blockSize.Width) / 2, (s.Height - blockSize.Height) / 2); AddChild(m_plabel); }
private void UserInputCallBack(IAsyncResult ia) { String res = Guide.EndShowKeyboardInput(ia); if (null != m_Image) { CCLabelTTF text = m_Image.parent.children [0].children [0] as CCLabelTTF; String languagename = text.getString(); if (String.Equals("中文", languagename)) { m_newChinese = res; } else { m_newEnglish = res; } } }
public override void OnEnter() { base.OnEnter(); //add the menu item for back to main menu CCLabelTTF label = new CCLabelTTF("MainMenu", "arial", 20); CCMenuItemLabel pMenuItem = new CCMenuItemLabel(label, MainMenuCallback); CCMenu pMenu = new CCMenu(pMenuItem); CCSize s = CCDirector.SharedDirector.WinSize; pMenu.Position = CCPoint.Zero; pMenuItem.Position = new CCPoint(s.Width - 50, 25); AddChild(pMenu, 1); CCApplication.SharedApplication.GamePadDPadUpdate += _GamePadDPadDelegate; CCApplication.SharedApplication.GamePadButtonUpdate += _GamePadButtonDelegate; }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; var label = new CCLabelTTF(title(), "arial", 32); AddChild(label, 0, kTagLabel); label.Position = new CCPoint(s.Width / 2, s.Height - 50); string subTitle = this.subtitle(); if (subTitle.Length > 0) { var l = new CCLabelTTF(subTitle, "arial", 16); AddChild(l, 1); l.Position = new CCPoint(s.Width / 2, s.Height - 80); } var item1 = new CCMenuItemImage(s_pPathB1, s_pPathB2, backCallback); var item2 = new CCMenuItemImage(s_pPathR1, s_pPathR2, restartCallback); var item3 = new CCMenuItemImage(s_pPathF1, s_pPathF2, nextCallback); var menu = new CCMenu(item1, item2, item3); menu.Position = CCPoint.Zero; item1.Position = new CCPoint(s.Width / 2 - item2.ContentSize.Width * 2, item2.ContentSize.Height / 2); item2.Position = new CCPoint(s.Width / 2, item2.ContentSize.Height / 2); item3.Position = new CCPoint(s.Width / 2 + item2.ContentSize.Width * 2, item2.ContentSize.Height / 2); AddChild(menu, 1); var itemMode = new CCMenuItemToggle(modeCallback, new CCMenuItemFont("Use High Quality Mode"), new CCMenuItemFont("Use Fast Mode") ); var menuMode = new CCMenu(itemMode); AddChild(menuMode); menuMode.Position = new CCPoint(s.Width / 2, s.Height / 4); }
public override bool Init() { if (base.Init()) { CCSize screenSize = CCDirector.SharedDirector.WinSize; // Add a label in which the slider value will be displayed m_pDisplayValueLabel = new CCLabelTTF("Move the slider thumb!\nThe lower slider is restricted.", "Arial", 32); m_pDisplayValueLabel.AnchorPoint = new CCPoint(0.5f, -1.0f); m_pDisplayValueLabel.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2.0f); AddChild(m_pDisplayValueLabel); // Add the slider var slider = new CCControlSlider("extensions/sliderTrack", "extensions/sliderProgress", "extensions/sliderThumb"); slider.AnchorPoint = new CCPoint(0.5f, 1.0f); slider.MinimumValue = 0.0f; // Sets the min value of range slider.MaximumValue = 5.0f; // Sets the max value of range slider.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f + 16); slider.Tag = 1; // When the value of the slider will change, the given selector will be call slider.AddTargetWithActionForControlEvents(this, valueChanged, CCControlEvent.ValueChanged); var restrictSlider = new CCControlSlider("extensions/sliderTrack", "extensions/sliderProgress", "extensions/sliderThumb"); restrictSlider.AnchorPoint = new CCPoint(0.5f, 1.0f); restrictSlider.MinimumValue = 0.0f; // Sets the min value of range restrictSlider.MaximumValue = 5.0f; // Sets the max value of range restrictSlider.MaximumAllowedValue = 4.0f; restrictSlider.MinimumAllowedValue = 1.5f; restrictSlider.Value = 3.0f; restrictSlider.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f - 24); restrictSlider.Tag = 2; //same with restricted restrictSlider.AddTargetWithActionForControlEvents(this, valueChanged, CCControlEvent.ValueChanged); AddChild(slider); AddChild(restrictSlider); return(true); } return(false); }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 32); addChild(label, 1); label.position = (new CCPoint(s.width / 2, s.height - 50)); CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(s_pPathB1, s_pPathB2, this, (backCallback)); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(s_pPathR1, s_pPathR2, this, (restartCallback)); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(s_pPathF1, s_pPathF2, this, (nextCallback)); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = new CCPoint(0, 0); item1.position = new CCPoint(s.width / 2 - 100, 30); item2.position = new CCPoint(s.width / 2, 30); item3.position = new CCPoint(s.width / 2 + 100, 30); addChild(menu, 1); }
public override bool Init() { if (base.Init()) { CCSize screenSize = CCDirector.SharedDirector.WinSize; var layer = new CCNode(); layer.Position = screenSize.Center; AddChild(layer, 1); float layer_width = 0; // Add the black background for the text CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png"); background.ContentSize = new CCSize(100, 50); background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0); layer.AddChild(background); DisplayValueLabel = new CCLabelTTF("0", "Arial", 26); _displayValueLabel.Position = background.Position; layer.AddChild(_displayValueLabel); layer_width += background.ContentSize.Width; CCControlStepper stepper = MakeControlStepper(); stepper.Position = new CCPoint(layer_width + 10 + stepper.ContentSize.Width / 2, 0); stepper.AddTargetWithActionForControlEvents(this, ValueChanged, CCControlEvent.ValueChanged); layer.AddChild(stepper); layer_width += stepper.ContentSize.Width; // Set the layer size layer.ContentSize = new CCSize(layer_width, 0); layer.AnchorPoint = new CCPoint(0.5f, 0.5f); // Update the value label ValueChanged(stepper, CCControlEvent.ValueChanged); return(true); } return(false); }
// on "init" you need to initialize your instance protected override void init() { base.init(); // create and initialize a Label CCLabelTTF label = new CCLabelTTF("Hello World", "Arial", 64); // ask director for the window size Vector2 size = CCDirector.sharedDirector.winSize; // position the label on the center of the screen label.position = size / 2; // add the label as a child to this Layer addChild(label); // // menu items // // Default font size will be 28 points. CCMenuItemFont.FontSize = 28; // Cocos2d Menu Item using blocks CCMenuItem itemCocos2d = new CCMenuItemFont("Cocos2d", delegate(CCMenuItem sender) { label.text = "Hello Cocos2d"; }); // Unity Menu Item using blocks CCMenuItem itemUnity = new CCMenuItemFont("Unity", delegate(CCMenuItem sender) { label.text = "Hello Unity"; }); CCMenu menu = new CCMenu(itemCocos2d, itemUnity); menu.alignItemsHorizontallyWithPadding(20); menu.position = new Vector2(size.x / 2, size.y / 2 - 50); // Add the menu to the layer addChild(menu); }
public TestLayer1() { float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCSprite bg1 = new CCSprite(TransitionsTestScene.s_back1); bg1.Position = (new CCPoint(size.Width / 2, size.Height / 2)); bg1.ScaleX = size.Width / bg1.ContentSize.Width; bg1.ScaleY = size.Height / bg1.ContentSize.Height; AddChild(bg1, -1); CCLabelTTF title = new CCLabelTTF((TransitionsTestScene.transitions[TransitionsTestScene.s_nSceneIdx]), "arial", 32); AddChild(title); title.Color = new CCColor3B(255, 32, 32); title.Position = new CCPoint(x / 2, y - 100); CCLabelTTF label = new CCLabelTTF("SCENE 1", "markerFelt", 38); label.Color = (new CCColor3B(16, 16, 255)); label.Position = (new CCPoint(x / 2, y / 2)); AddChild(label); // menu CCMenuItemImage item1 = new CCMenuItemImage(TransitionsTestScene.s_pPathB1, TransitionsTestScene.s_pPathB2, backCallback); CCMenuItemImage item2 = new CCMenuItemImage(TransitionsTestScene.s_pPathR1, TransitionsTestScene.s_pPathR2, restartCallback); CCMenuItemImage item3 = new CCMenuItemImage(TransitionsTestScene.s_pPathF1, TransitionsTestScene.s_pPathF2, nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = CCPoint.Zero; item1.Position = new CCPoint(x / 2 - item2.ContentSize.Width * 2, item2.ContentSize.Height / 2); item2.Position = new CCPoint(x / 2, item2.ContentSize.Height / 2); item3.Position = new CCPoint(x / 2 + item2.ContentSize.Width * 2, item2.ContentSize.Height / 2); AddChild(menu, 1); Schedule(step, 1.0f); }
public override void Update(float dt) { base.Update(dt); elapsedTime += dt; if (elapsedTime > 3f) { if (_TheTexture != null) { _TheTexture.XNATexture.Dispose(); _TheTexture = null; } CreateTheButtons(); elapsedTime = 0f; var title = new CCLabelTTF("Refreshing the buttons", "Arial", 30); AddChild(title, 25); title.Position = ContentSize.Center; title.RunAction(new CCFadeOut(1f)); } }
public override bool Init() { base.Init(); CCSize s = CCDirector.SharedDirector.WinSize; CCSprite background = new CCSprite(TestResource.s_back3); background.AnchorPoint = new CCPoint(0.5f, 0.5f); background.Position = s.Center; AddChild(background, -1); var label = new CCLabelTTF(title(), "arial", 32); AddChild(label, 1); label.Position = (new CCPoint(s.Width / 2, s.Height - 50)); string subtitle_ = subtitle(); if (subtitle_.Length > 0) { var l = new CCLabelTTF(subtitle_, "arial", 16); AddChild(l, 1); l.Position = (new CCPoint(s.Width / 2, s.Height - 80)); } var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); var menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(s.Width / 2 - 100, 30); item2.Position = new CCPoint(s.Width / 2, 30); item3.Position = new CCPoint(s.Width / 2 + 100, 30); AddChild(menu, 1); Setup(); return(true); }
/// <summary> /// /// </summary> /// <param name="p_Layer"></param> /// <param name="p_Text"></param> /// <param name="p_LeftButtonPic"></param> /// <param name="p_RightButtonPic"></param> /// <param name="y"></param> public static void AddSetMenu(CCLayer p_Layer, String p_Text, String p_LeftButtonPic, String p_RightButtonPic, SEL_MenuHandler p_LeftHandle, SEL_MenuHandler p_RightHandle, ref float y) { CCLabelTTF language = CCLabelTTF.labelWithString(p_Text, "ChineseTitle", 28); language.Color = new ccColor3B(Color.White); CCMenuItemLabel tab1 = CCMenuItemLabel.itemWithLabel(language); //CCTexture2D cctext2D1 = Media.PictureManager.GetCCTexture2D(p_LeftButtonPic); //CCSprite sprite1 = CCSprite.spriteWithTexture(cctext2D1); CCMenuItemSprite tab2 = CCMenuItemImage.itemFromNormalImage(p_LeftButtonPic, null, p_Layer, p_LeftHandle); //CCTexture2D cctext2D2 = Media.PictureManager.GetCCTexture2D(p_RightButtonPic); // CCSprite sprite2 = CCSprite.spriteWithTexture(cctext2D2); CCMenuItemSprite tab3 = CCMenuItemImage.itemFromNormalImage(p_RightButtonPic, null, p_Layer, p_RightHandle); CCMenu p_Menu1 = CCMenu.menuWithItems(tab1); CCMenu p_Menu2 = CCMenu.menuWithItems(tab2); CCMenu p_Menu3 = CCMenu.menuWithItems(tab3); //position p_Menu2 float textwidth = tab1.contentSize.width < 40 ? 40 : tab1.contentSize.width; float displayCenter = CCDirector.sharedDirector().displaySizeInPixels.width / 2; float x2 = displayCenter - textwidth; float x1 = displayCenter; float x3 = displayCenter + textwidth; float y2 = y + (tab1.contentSize.height - tab2.contentSize.height) / 2; p_Menu2.position = new CCPoint(x2, y2); p_Menu1.position = new CCPoint(x1, y); p_Menu3.position = new CCPoint(x3, y2); p_Layer.addChild(p_Menu2); p_Layer.addChild(p_Menu1); p_Layer.addChild(p_Menu3); y -= tab2.contentSize.height + Blank; }
public TextLayer() : base() { SizeF s = CCDirector.SharedDirector ().WinSize (); float x = s.Width; float y = s.Height; CCNode node = new CCNode (); CCAction effectClass = RestartAction (3f); node.RunAction (effectClass); this.AddChild (node, 0, (int)EffectLayers.kTagBackground); CCSprite bg = new CCSprite ("background3.png", true); node.AddChild (bg, 0); bg.Position = new PointF(x/2, y/2); CCSprite grossini = new CCSprite ("grossinis_sister2.png", true); node.AddChild (grossini, 1); grossini.Position = new PointF(x/3, y/2); CCScaleBy sc = new CCScaleBy (2, 5); CCActionInterval sc_back = sc.Reverse (); grossini.RunAction (new CCRepeatForever (new CCSequence (sc, sc_back))); CCSprite tamara = new CCSprite ("grossinis_sister1.png", true); node.AddChild (tamara, 1, (int)EffectLayers.kTagSprite2); tamara.Position = new PointF (2*x/3, y/2); CCScaleBy sc2 = new CCScaleBy (2, 5); CCActionInterval sc2_back = sc2.Reverse (); tamara.RunAction (new CCRepeatForever (new CCSequence (sc2, sc2_back))); CCLabelTTF label = new CCLabelTTF (effectsList[actionIdx].Replace("Demo", ""), "Marker Felt", 32); label.Position = new PointF (x/2, y-80); this.AddChild (label); label.Tag = (int)EffectLayers.kTagLabel; //menu CCMenuItemImage item1 = new CCMenuItemImage ("b1.png", "b2.png", null, BackCallback); CCMenuItemImage item2 = new CCMenuItemImage ("r1.png", "r2.png", null, RestartCallback); CCMenuItemImage item3 = new CCMenuItemImage ("f1.png", "f2.png", null, NextCallback); CCMenu menu = new CCMenu (item1, item2, item3); menu.Position = PointF.Empty; item1.Position = new PointF(s.Width/2 - item2.ContentSize.Width*2, item2.ContentSize.Height/2); item2.Position = new PointF( s.Width/2, item2.ContentSize.Height/2); item3.Position = new PointF( s.Width/2 + item2.ContentSize.Width*2, item2.ContentSize.Height/2); this.AddChild (menu, 1); this.Schedule (new MonoMac.ObjCRuntime.Selector ("checkAnim:")); }
protected void RecreateLabel() { CCLabelTTF label = new CCLabelTTF((m_pLabel as ICCLabelProtocol).Label, m_strFontName, m_uFontSize); Label = label; }