public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80)); layer.IgnoreAnchorPointForPosition = false; layer.Position = (new CCPoint(s.Width / 2, s.Height / 2)); AddChild(layer, 1, kTagLayer); // // Add two labels using BM label class // CCLabelBMFont var label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt"); layer.AddChild(label1); label1.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.75f); var label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt"); layer.AddChild(label2); label2.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.25f); // // Do the sequence of actions in the bug report layer.Visible = false; layer.RunActions(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5); }
public GridScene(CCGameView gameView) : base(gameView) { var layer = new CCLayerColor(CCColor4B.Transparent); var profilepos = (App.ScreenHeight / 5.25f); var boardpos = (App.ScreenHeight / 2.50f) + (App.ScreenHeight / 5f); var letpos = (App.ScreenHeight / 2.50f) + (App.ScreenHeight / 5f) + (App.ScreenHeight / 9f); var bankpos = (App.ScreenHeight / 2.50f) + (App.ScreenHeight / 5f) + (App.ScreenHeight / 9.25f) + (App.ScreenHeight / 5.5f); //var menpos = (App.ScreenHeight / 2.50f) + (App.ScreenHeight / 5f) + (App.ScreenHeight / 9.25f) + (App.ScreenHeight / 5.5f) + (App.ScreenHeight / 10f); this.AddLayer(layer); CCRect rectprof = new CCRect(0, App.ScreenHeight - profilepos, App.ScreenWidth, App.ScreenHeight / 5.25f); // CCRect rect = new CCRect(0, App.ScreenHeight - boardpos, App.ScreenWidth, App.ScreenHeight / 2.50f); CCRect rectlet = new CCRect(0, App.ScreenHeight - letpos, App.ScreenWidth, App.ScreenHeight / 9.25f); CCRect recbank = new CCRect(0, App.ScreenHeight - bankpos, App.ScreenWidth, App.ScreenHeight / 5.75f); CCRect recmen = new CCRect(0, 0, App.ScreenWidth, App.ScreenHeight / 9.5f); ProfileBoard.DrawRect(rectprof, CCColor4B.White); // GameBoard.DrawRect(rect,CCColor4B.Red); GameBoard.Position = new CCPoint(0, App.ScreenHeight - boardpos); GameBoard.ContentSize = new CCSize(App.ScreenWidth, App.ScreenHeight / 2.50f); LetterBoard.DrawRect(rectlet, CCColor4B.AliceBlue); AnswerBank.DrawRect(recbank, CCColor4B.Orange); Menus.DrawRect(recmen, CCColor4B.Green); _grid = new CCSprite("Images/Sprites/wordframe.png"); GameboardCreation(); layer.AddChild(GameBoard); layer.AddChild(ProfileBoard); layer.AddChild(LetterBoard); layer.AddChild(AnswerBank); layer.AddChild(Menus); }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255)); layer1.IsColorCascaded = false; layer1.Position = new CCPoint(0, s.Height / 2); var sister1 = new CCSprite("Images/grossinis_sister1.png"); var sister2 = new CCSprite("Images/grossinis_sister2.png"); var label = new CCLabel("Test", "fonts/bitmapFontTest.fnt"); // by default a CCLabelBMFont has IsColorModifiedByOpacity on by default if the // texture atlas is PreMultipliedAlpha. Label as used by Cocos2d-x by default has // this set to false. Maybe this is a bug in Cocos2d-x? label.IsColorModifiedByOpacity = false; layer1.AddChild(sister1); layer1.AddChild(sister2); layer1.AddChild(label); this.AddChild(layer1, 0, kTagLayer); sister1.Position = new CCPoint(s.Width * 1 / 3, 0); sister2.Position = new CCPoint(s.Width * 2 / 3, 0); label.Position = new CCPoint(s.Width / 2, 0); // Define our delay time var delay = new CCDelayTime(1); layer1.RepeatForever( new CCFadeTo(4, 0), new CCFadeTo(4, 255), delay ); // We only have to define them once. var fadeTo11 = new CCFadeTo(2, 0); var fadeTo12 = new CCFadeTo(2, 255); sister1.RepeatForever( fadeTo11, fadeTo12, fadeTo11, fadeTo12, delay ); // Enable cascading in scene SetEnableRecursiveCascading(this, true); }
public override void OnEnter() { base.OnEnter(); var s = CCDirector.SharedDirector.WinSize; var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255), s.Width, s.Height / 2); layer1.CascadeColorEnabled = false; layer1.Position = new CCPoint(0, s.Height / 2); var sister1 = new CCSprite("Images/grossinis_sister1.png"); var sister2 = new CCSprite("Images/grossinis_sister2.png"); var label = new CCLabelBMFont("Test", "fonts/bitmapFontTest.fnt"); layer1.AddChild(sister1); layer1.AddChild(sister2); layer1.AddChild(label); this.AddChild(layer1, 0, kTagLayer); sister1.Position = new CCPoint(s.Width * 1 / 3, 0); sister2.Position = new CCPoint(s.Width * 2 / 3, 0); label.Position = new CCPoint(s.Width / 2, 0); layer1.RunAction( new CCRepeatForever( new CCSequence( new CCTintTo(6, 255, 0, 255), new CCTintTo(6, 255, 255, 255), new CCDelayTime(1)) ) ); sister1.RunAction( new CCRepeatForever( new CCSequence( new CCTintTo(2, 255, 255, 0), new CCTintTo(2, 255, 255, 255), new CCTintTo(2, 0, 255, 255), new CCTintTo(2, 255, 255, 255), new CCTintTo(2, 255, 0, 255), new CCTintTo(2, 255, 255, 255), new CCDelayTime(1)) ) ); // Enable cascading in scene SetEnableRecursiveCascading(this, true); }
public AnimationModel() { var cocosSharpView = new CocosSharpView(); cocosSharpView.ViewCreated += (sender, e) => { var gameView = sender as CCGameView; var cocosSharpViewWidth = cocosSharpView.Width; var cocosSharpViewHeight = cocosSharpView.Height; gameView.DesignResolution = new CCSizeI((int)cocosSharpViewWidth, (int)cocosSharpViewHeight); var scene = new CCScene(gameView); var layer = new CCLayerColor(CCColor4B.White); hito = new CCSprite("hito.png", null); hito.Scale = 0.5f; firstPositionX = 0 - (hito.ContentSize.Width / 2); firstPositionY = (float)cocosSharpViewHeight / 2; hito.PositionX = firstPositionX; hito.PositionY = firstPositionY; distance = (float)cocosSharpViewWidth + hito.ContentSize.Width; layer.AddChild(hito); scene.AddLayer(layer); gameView.RunWithScene(scene); }; Content = cocosSharpView; }
public LayerMultiplexTest() { for (int i = 0; i < 3; i++) { CCLayer l = new CCLayerColor(new CCColor4B(0, 255, 0)); CCSprite img = null; switch (i) { case 0: img = new CCSprite("Images/grossini"); break; case 1: img = new CCSprite("Images/grossinis_sister1"); break; case 2: img = new CCSprite("Images/grossinis_sister2"); break; } img.AnchorPoint = CCPoint.Zero; img.Position = CCPoint.Zero; l.ContentSize = img.ContentSize; l.AddChild(img); l.Position = new CCPoint(128f, 128f); child.AddLayer(l); } child.InAction = new CCFadeIn(1); AddChild(child); Schedule(new Action <float>(AutoMultiplex), 3f); }
public override void OnEnter() { base.OnEnter(); CCActionInterval effect = (new CCSequence(new CCDelayTime(2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false))); // cleanup CCNode bg = GetChildByTag(EffectAdvanceScene.kTagBackground); RemoveChild(bg, true); // background CCLayerColor layer = new CCLayerColor(new CCColor4B(255, 0, 0, 255)); AddChild(layer, -10); CCSprite sprite = new CCSprite("Images/grossini"); sprite.Position = new CCPoint(50, 80); layer.AddChild(sprite, 10); // foreground CCLayerColor layer2 = new CCLayerColor(new CCColor4B(0, 255, 0, 255)); CCSprite fog = new CCSprite("Images/Fog"); var bf = new CCBlendFunc { Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA }; fog.BlendFunc = bf; layer2.AddChild(fog, 1); AddChild(layer2, 1); layer2.RunAction(new CCRepeatForever(effect)); }
public override void OnEnter() { base.OnEnter(); var effect = new CCSequence(new CCDelayTime(2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false)); // cleanup RemoveChild(bgNode, true); // background var layer = new CCLayerColor(new CCColor4B(255, 0, 0, 255)); AddChild(layer, -10); var sprite = new CCSprite("Images/grossini"); sprite.Position = new CCPoint(50, 80); layer.AddChild(sprite, 10); // foreground var layer2Node = new CCNode(); var layer2 = new CCLayerColor(new CCColor4B(0, 255, 0, 255)); var fog = new CCSprite("Images/Fog"); var bf = new CCBlendFunc { Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA }; fog.BlendFunc = bf; layer2.AddChild(fog, 1); AddChild(layer2Node, 1); layer2Node.AddChild(layer2); layer2Node.RepeatForever(effect); }
void LoadGame(object sender, EventArgs e) { var nativeGameView = sender as CCGameView; if (nativeGameView != null) { var contentSearchPaths = new List <string>() { "Fonts", "Sounds" }; CCSizeI viewSize = nativeGameView.ViewSize; CCSizeI designResolution = nativeGameView.DesignResolution; _gameView.DesignResolution = new Size(viewSize.Width, viewSize.Height); nativeGameView.ContentManager.SearchPaths = contentSearchPaths; //create a scrollview with the correct viewsize and an area to move in the size of 3000 by 3000 var scrollView = new ScrollViewInAction(nativeGameView.ViewSize); scrollView.BouncingRectSize = new CCSize(3000, 3000); var scrollLayer = new CCLayerColor(CCColor4B.White); scrollLayer.AddChild(scrollView); CCScene gameScene = new CCScene(nativeGameView); gameScene.AddLayer(scrollLayer); nativeGameView.RunWithScene(gameScene); } }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255)); layer1.IsColorCascaded = false; layer1.Position = new CCPoint(0, s.Height / 2); var sister1 = new CCSprite("Images/grossinis_sister1.png"); var sister2 = new CCSprite("Images/grossinis_sister2.png"); var label = new CCLabel("Test", "fonts/bitmapFontTest.fnt"); layer1.AddChild(sister1); layer1.AddChild(sister2); layer1.AddChild(label); this.AddChild(layer1, 0, kTagLayer); sister1.Position = new CCPoint(s.Width * 1 / 3, 0); sister2.Position = new CCPoint(s.Width * 2 / 3, 0); label.Position = new CCPoint(s.Width / 2, 0); // Define our delay time var delay = new CCDelayTime(1); layer1.RepeatForever( new CCTintTo(6, 255, 0, 255), new CCTintTo(6, 255, 255, 255), delay ); sister1.RepeatForever( new CCTintTo(2, 255, 255, 0), new CCTintTo(2, 255, 255, 255), new CCTintTo(2, 0, 255, 255), new CCTintTo(2, 255, 255, 255), new CCTintTo(2, 255, 0, 255), new CCTintTo(2, 255, 255, 255), delay ); // Enable cascading in scene SetEnableRecursiveCascading(this, true); }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255)); layer1.IsColorCascaded = false; layer1.Position = new CCPoint(0, s.Height / 2); var sister1 = new CCSprite("Images/grossinis_sister1.png"); var sister2 = new CCSprite("Images/grossinis_sister2.png"); var label = new CCLabel("Test", "fonts/bitmapFontTest.fnt"); layer1.AddChild(sister1); layer1.AddChild(sister2); layer1.AddChild(label); this.AddChild(layer1, 0, kTagLayer); sister1.Position = new CCPoint(s.Width * 1 / 3, 0); sister2.Position = new CCPoint(s.Width * 2 / 3, 0); label.Position = new CCPoint(s.Width / 2, 0); // Define our delay time var delay = new CCDelayTime(1); layer1.RepeatForever( new CCFadeTo(4, 0), new CCFadeTo(4, 255), delay ); // We only have to define them once. var fadeTo11 = new CCFadeTo(2, 0); var fadeTo12 = new CCFadeTo(2, 255); sister1.RepeatForever( fadeTo11, fadeTo12, fadeTo11, fadeTo12, delay ); }
public override void OnEnter() { base.OnEnter(); m_tamara.RemoveFromParentAndCleanup(true); m_grossini.RemoveFromParentAndCleanup(true); m_kathia.RemoveFromParentAndCleanup(true); // Get window size so that we can center the box layer var winSize = CCDirector.SharedDirector.WinSize; var boxSize = new CCSize(100.0f, 100.0f); var box = new CCLayerColor(new CCColor4B(255, 255, 0, 255)); box.AnchorPoint = new CCPoint(0, 0); box.Position = new CCPoint(winSize.Center.X - (boxSize.Width / 2), winSize.Center.Y - (boxSize.Height / 2)); box.ContentSize = boxSize; var uL = new CCLayerColor(new CCColor4B(255, 0, 0, 255)); box.AddChild(uL); uL.ContentSize = new CCSize(markrside, markrside); uL.Position = new CCPoint(0.0f, boxSize.Height - markrside); uL.AnchorPoint = new CCPoint(0, 0); var uR = new CCLayerColor(new CCColor4B(0, 0, 255, 255)); box.AddChild(uR); uR.ContentSize = new CCSize(markrside, markrside); uR.Position = new CCPoint(boxSize.Width - markrside, boxSize.Height - markrside); uR.AnchorPoint = new CCPoint(0, 0); AddChild(box); var actionTo = new CCSkewTo(2, 0.0f, 2.0f); var rotateTo = new CCRotateTo(2, 61.0f); var actionScaleTo = new CCScaleTo(2, -0.44f, 0.47f); var actionScaleToBack = new CCScaleTo(2, 1.0f, 1.0f); var rotateToBack = new CCRotateTo(2, 0); var actionToBack = new CCSkewTo(2, 0, 0); box.RunAction(CCSequence.FromActions(actionTo, actionToBack)); box.RunAction(CCSequence.FromActions(rotateTo, rotateToBack)); box.RunAction(CCSequence.FromActions(actionScaleTo, actionScaleToBack)); }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(0xFF, 0xFF, 0x00, 0x80)); layer1.IgnoreAnchorPointForPosition = false; layer1.Position = (new CCPoint(s.Width / 2, s.Height / 2)); layer1.ChildClippingMode = CCClipMode.Bounds; AddChild(layer1, 1); s = layer1.ContentSize; m_pInnerLayer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80)); m_pInnerLayer.IgnoreAnchorPointForPosition = false; m_pInnerLayer.Position = (new CCPoint(s.Width / 2, s.Height / 2)); m_pInnerLayer.ChildClippingMode = CCClipMode.Bounds; layer1.AddChild(m_pInnerLayer, 1); // // Add two labels using BM label class // CCLabelBMFont CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt"); label1.Position = new CCPoint(m_pInnerLayer.ContentSize.Width, m_pInnerLayer.ContentSize.Height * 0.75f); m_pInnerLayer.AddChild(label1); CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt"); label2.Position = new CCPoint(0, m_pInnerLayer.ContentSize.Height * 0.25f); m_pInnerLayer.AddChild(label2); CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 3.0f); CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 1.0f); m_pInnerLayer.RepeatForever(scaleTo2, scaleTo3); CCFiniteTimeAction seq = new CCRepeatForever( new CCSequence(scaleTo2, scaleTo3) ); m_pInnerLayer.RunAction(seq); CCSize size = Layer.VisibleBoundsWorldspace.Size; var move1 = new CCMoveTo(2, new CCPoint(size.Width / 2, size.Height)); var move2 = new CCMoveTo(2, new CCPoint(size.Width, size.Height / 2)); var move3 = new CCMoveTo(2, new CCPoint(size.Width / 2, 0)); var move4 = new CCMoveTo(2, new CCPoint(0, size.Height / 2)); layer1.RunAction(new CCRepeatForever(new CCSequence(move1, move2, move3, move4))); }
public override void OnEnter() { base.OnEnter(); this.TouchEnabled = true; CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f); layer.IgnoreAnchorPointForPosition = false; layer.Position = (new CCPoint(s.Width / 2, s.Height / 2)); AddChild(layer, 1, kTagLayer); // // Add two labels using BM label class // CCLabelBMFont CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt"); layer.AddChild(label1); label1.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.75f); CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt"); layer.AddChild(label2); label2.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.25f); // // Do the sequence of actions in the bug report float waitTime = 3f; float runTime = 12f; layer.Visible = false; CCHide hide = new CCHide(); CCScaleTo scaleTo1 = new CCScaleTo(0.0f, 0.0f); CCShow show = new CCShow(); CCDelayTime delay = new CCDelayTime(waitTime); CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 1.2f); CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 0.95f); CCScaleTo scaleTo4 = new CCScaleTo(runTime * 0.25f, 1.1f); CCScaleTo scaleTo5 = new CCScaleTo(runTime * 0.25f, 1.0f); CCFiniteTimeAction seq = CCSequence.FromActions(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5); layer.RunAction(seq); }
public MainScene(CCGameView gameView) : base(gameView) { var layer = new CCLayerColor(CCColor4B.Transparent); this.AddLayer(layer); _background = new CCSprite("Images/Background/bg.png"); _logo = new CCSprite("Images/Sprites/logo_tokblitz.png"); _logo.setSizeLogoLarge(); _logo.Position = new CCPoint(App.ScreenWidth / 2, App.ScreenHeight / 2); _background.ContentSize = CustomSize.FullScreen; _background.Position = new CCPoint(App.ScreenWidth / 2, App.ScreenHeight / 2); layer.AddChild(_background); _background.AddChild(_logo); }
public override void OnEnter() { base.OnEnter(); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCNode blue = new CCLayerColor(new CCColor4B(0, 0, 255, 255)); CCNode red = new CCLayerColor(new CCColor4B(255, 0, 0, 255)); CCNode green = new CCLayerColor(new CCColor4B(0, 255, 0, 255)); CCNode white = new CCLayerColor(new CCColor4B(255, 255, 255, 255)); blue.Scale = (0.5f); blue.Position = (new CCPoint(-x / 4, -y / 4)); blue.AddChild(SpriteLayer.node()); red.Scale = (0.5f); red.Position = (new CCPoint(x / 4, -y / 4)); green.Scale = (0.5f); green.Position = (new CCPoint(-x / 4, y / 4)); green.AddChild(TestLayer.node()); white.Scale = (0.5f); white.Position = (new CCPoint(x / 4, y / 4)); AddChild(blue, -1); AddChild(white); AddChild(green); AddChild(red); CCAction rot = new CCRotateBy(8, 720); blue.RunAction(rot); red.RunAction((CCAction)(rot.Copy())); green.RunAction((CCAction)(rot.Copy())); white.RunAction((CCAction)(rot.Copy())); }
void HandleViewCreated(object sender, EventArgs e) { var gameView = sender as CCGameView; if (gameView != null) { // This sets the game "world" resolution to 100x100: gameView.DesignResolution = new CCSizeI(100, 100); // GameScene is the root of the CocosSharp rendering hierarchy: //gameScene = new GameScene(gameView); gamescene = new CCScene(gameView); //add sprtie to layer add layer to scene var layer = new CCLayerColor(); var box = new CCDrawNode(); box.DrawRect(new CCPoint(50, 50), 25, CCColor4B.Red); layer.AddChild(box); gamescene.AddLayer(layer); // Starts CocosSharp: gameView.RunWithScene(gamescene); } }
public override void ApplicationDidFinishLaunching(CCApplication app, CCWindow window) { app.PreferMultiSampling = false; app.ContentRootDirectory = "Content"; app.ContentSearchPaths.Add("hd"); CCScene scene = new CCScene(window); CCLayerColor layer = new CCLayerColor(); var label = new CCLabel("Tap Screen To Play!", "MarkerFelt-22", 22) { Position = layer.VisibleBoundsWorldspace.Center, Color = CCColor3B.Black, HorizontalAlignment = CCTextAlignment.Center, VerticalAlignment = CCVerticalTextAlignment.Center, AnchorPoint = CCPoint.AnchorLowerLeft, Dimensions = layer.ContentSize }; layer.AddChild(label); scene.AddChild(layer); window.RunWithScene(scene); }
public override void OnEnter() { base.OnEnter(); // create a transparent color layer // in which we are going to add our rendertextures var color = new CCColor4B(0, 0, 0, 0); CCSize size = CCDirector.SharedDirector.WinSize; CCLayerColor layer = new CCLayerColor(color); // create the first render texture for inScene CCRenderTexture inTexture = new CCRenderTexture((int) size.Width, (int) size.Height); if (null == inTexture) { return; } inTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); inTexture.Position = new CCPoint(size.Width / 2, size.Height / 2); inTexture.AnchorPoint = new CCPoint(0.5f, 0.5f); // render inScene to its texturebuffer inTexture.Begin(); m_pInScene.Visit(); inTexture.End(); // create the second render texture for outScene CCRenderTexture outTexture = new CCRenderTexture((int) size.Width, (int) size.Height); outTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); outTexture.Position = new CCPoint(size.Width / 2, size.Height / 2); outTexture.AnchorPoint = new CCPoint(0.5f, 0.5f); // render outScene to its texturebuffer outTexture.Begin(); m_pOutScene.Visit(); outTexture.End(); // create blend functions var blend1 = new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE); // inScene will lay on background and will not be used with alpha var blend2 = CCBlendFunc.NonPremultiplied; // we are going to blend outScene via alpha // set blendfunctions inTexture.Sprite.BlendFunc = blend1; outTexture.Sprite.BlendFunc = blend2; // add render textures to the layer layer.AddChild(inTexture); layer.AddChild(outTexture); // initial opacity: inTexture.Sprite.Opacity = 255; outTexture.Sprite.Opacity = 255; // create the blend action CCAction layerAction = CCSequence.FromActions ( new CCFadeTo (m_fDuration, 0), new CCCallFunc((HideOutShowIn)), new CCCallFunc((Finish)) ); //// run the blend action outTexture.Sprite.RunAction(layerAction); // add the layer (which contains our two rendertextures) to the scene AddChild(layer, 2, kSceneFade); }
//--------------------------------------------------------------------------------------------------------- // NewGame - Used in menu selection //--------------------------------------------------------------------------------------------------------- // Transitions to LevelLayer //--------------------------------------------------------------------------------------------------------- void NewGame(object stuff = null) { if (currentPlayer.BranchProgression[1].LastLevelCompleted > -1) { //if (currentPlayer.LastLevelCompleted > -1) { CCRect bounds = VisibleBoundsWorldspace; PauseListeners(true); Application.Paused = true; var newGameLayer = new CCLayerColor(new CCColor4B(0, 0, 0, 230)); AddChild(newGameLayer, 99999); // Add frame to layer frameSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("frame.png"))); frameSprite.AnchorPoint = CCPoint.AnchorMiddle; frameSprite.Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2); newGameLayer.AddChild(frameSprite); newGameWarning = new CCLabel("This will erase your current progress!\n\n\nProceed?", GOTHIC_56_WHITE_FNT); newGameWarning.AnchorPoint = CCPoint.AnchorMiddle; newGameWarning.Scale = 1.5f; newGameWarning.Position = new CCPoint(frameSprite.BoundingBox.Center); newGameWarning.HorizontalAlignment = CCTextAlignment.Center; newGameLayer.AddChild(newGameWarning); okLabel = new CCLabel("OK", GOTHIC_44_HD_FNT); okLabel.AnchorPoint = CCPoint.AnchorMiddle; okLabel.Scale = 1.5f; cancelLabel = new CCLabel("Cancel", GOTHIC_44_HD_FNT); cancelLabel.AnchorPoint = CCPoint.AnchorMiddle; cancelLabel.Scale = 1.5f; var okItem = new CCMenuItemLabel(okLabel, okSender => { newGameLayer.RemoveFromParent(); ResumeListeners(true); Application.Paused = false; currentPlayer = new Player(); currentPlayer.WriteData(currentPlayer); var mainGame = LevelLayer.CreateScene(Window, levels, currentPlayer); var transitionToGame = new CCTransitionFade(2.0f, mainGame); Director.ReplaceScene(transitionToGame); }); okItem.Position = bounds.Center; var cancelItem = new CCMenuItemLabel(cancelLabel, cancelSender => { newGameLayer.RemoveFromParent(); ResumeListeners(true); Application.Paused = false; }); cancelItem.Position = bounds.Center; var closeMenu = new CCMenu(okItem, cancelItem); closeMenu.AlignItemsHorizontally(50); closeMenu.AnchorPoint = CCPoint.AnchorMiddleBottom; closeMenu.Position = new CCPoint(bounds.Size.Width / 2, frameSprite.BoundingBox.MinY + (okLabel.BoundingBox.Size.Height * 2.5f)); newGameLayer.AddChild(closeMenu); } else { var mainGame = LevelLayer.CreateScene(Window, levels, currentPlayer); var transitionToGame = new CCTransitionFade(2.0f, mainGame); Director.ReplaceScene(transitionToGame); } }
//--------------------------------------------------------------------------------------------------------- // PlayerStats //--------------------------------------------------------------------------------------------------------- // Show player information summary in a popup //--------------------------------------------------------------------------------------------------------- void PlayerStats(object stuff = null) { CCRect bounds = VisibleBoundsWorldspace; PauseListeners(true); Application.Paused = true; var playerStatsLayer = new CCLayerColor(new CCColor4B(0, 0, 0, 230)); AddChild(playerStatsLayer, 99999); // Add frame to layer frameSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("frame.png"))); frameSprite.AnchorPoint = CCPoint.AnchorMiddle; frameSprite.Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2); frameSprite.ScaleY = 1.3f; playerStatsLayer.AddChild(frameSprite); var titleLabel = new CCLabel("Player Stats", GOTHIC_56_WHITE_HD_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1f }; var titleMenuItem = new CCMenuItemLabel(titleLabel); var playerNameLabel = new CCLabel(string.Format("Player Name: {0}", currentPlayer.Name), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var playerNameMenuItem = new CCMenuItemLabel(playerNameLabel); //var lastLevelLabel = new CCLabel (string.Format ("Last Level Completed: {0}", currentPlayer.LastLevelCompleted), GOTHIC_56_WHITE_FNT) { var lastLevelLabel = new CCLabel(string.Format("Last Level Completed: {0}", currentPlayer.BranchProgression[1].LastLevelCompleted), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var lastLevelMenuItem = new CCMenuItemLabel(lastLevelLabel); var coinsLabel = new CCLabel(string.Format("Coins: {0}", currentPlayer.Coins), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var coinsMenuItem = new CCMenuItemLabel(coinsLabel); var highScoreLabel = new CCLabel(string.Format("High Score: {0}", currentPlayer.TotalScores), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var highScoreMenuItem = new CCMenuItemLabel(highScoreLabel); var tapStrengthLabel = new CCLabel(string.Format("Tap Strength: {0}", currentPlayer.PersistentTapStrength), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var tapStrengthMenuItem = new CCMenuItemLabel(tapStrengthLabel); var percentChanceNextSeqLabel = new CCLabel(string.Format("Next in Sequence Luck: {0}%", currentPlayer.ChanceToRollNextSeq), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var percentChanceNextSeqMenuItem = new CCMenuItemLabel(percentChanceNextSeqLabel); var percentChanceBonusLabel = new CCLabel(string.Format("Bonus Bubble Luck: {0}%", currentPlayer.ChanceToRollBonus), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var percentChanceBonusMenuItem = new CCMenuItemLabel(percentChanceBonusLabel); var timeBonusLabel = new CCLabel(string.Format("Additional Level Time: {0} Seconds", currentPlayer.PersistentTimeBonus), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var timeBonusMenuItem = new CCMenuItemLabel(timeBonusLabel); var time2xBonusLabel = new CCLabel(string.Format("2x Bonus Timer Extra: {0} Seconds", currentPlayer.Persistent2xTimeBonus), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var time2xBonusMenuItem = new CCMenuItemLabel(time2xBonusLabel); var time3xBonusLabel = new CCLabel(string.Format("3x Bonus Timer Extra: {0} Seconds", currentPlayer.Persistent3xTimeBonus), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var time3xBonusMenuItem = new CCMenuItemLabel(time3xBonusLabel); var highlightNextAvailableLabel = new CCLabel("Highlight Next Sequence Bubble: " + ((currentPlayer.HighlightNextPurchased) ? "Yes" : "No"), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = Scale = 1.0f }; var highlightNextMenuItem = new CCMenuItemLabel(highlightNextAvailableLabel); var okButtonLabel = new CCLabel("OK", GOTHIC_30_HD_FNT) { AnchorPoint = AnchorPoint = CCPoint.AnchorMiddle, Scale = 2.0f }; var okButtonMenuItem = new CCMenuItemLabel(okButtonLabel, okSender => { playerStatsLayer.RemoveFromParent(); ResumeListeners(true); Application.Paused = false; }); var playerStatsMenu = new CCMenu(titleMenuItem, playerNameMenuItem, lastLevelMenuItem, coinsMenuItem, highScoreMenuItem, tapStrengthMenuItem, percentChanceNextSeqMenuItem, percentChanceBonusMenuItem, timeBonusMenuItem, time2xBonusMenuItem, time3xBonusMenuItem, highlightNextMenuItem, okButtonMenuItem); playerStatsMenu.AnchorPoint = CCPoint.AnchorMiddle; playerStatsMenu.Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2); playerStatsMenu.AlignItemsVertically(40); playerStatsLayer.AddChild(playerStatsMenu); }
public override void OnEnter() { base.OnEnter(); // create a transparent color layer // in which we are going to add our rendertextures var color = new CCColor4B(0, 0, 0, 0); CCSize size = CCDirector.SharedDirector.WinSize; CCLayerColor layer = new CCLayerColor(color); // create the first render texture for inScene CCRenderTexture inTexture = new CCRenderTexture((int)size.Width, (int)size.Height); if (null == inTexture) { return; } inTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); inTexture.Position = new CCPoint(size.Width / 2, size.Height / 2); inTexture.AnchorPoint = new CCPoint(0.5f, 0.5f); // render inScene to its texturebuffer inTexture.Begin(); m_pInScene.Visit(); inTexture.End(); // create the second render texture for outScene CCRenderTexture outTexture = new CCRenderTexture((int)size.Width, (int)size.Height); outTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); outTexture.Position = new CCPoint(size.Width / 2, size.Height / 2); outTexture.AnchorPoint = new CCPoint(0.5f, 0.5f); // render outScene to its texturebuffer outTexture.Begin(); m_pOutScene.Visit(); outTexture.End(); // create blend functions var blend1 = new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE); // inScene will lay on background and will not be used with alpha var blend2 = new CCBlendFunc(CCMacros.CCDefaultSourceBlending, CCMacros.CCDefaultDestinationBlending); // OGLES.GL_SRC_ALPHA, OGLES.GL_ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha // set blendfunctions inTexture.Sprite.BlendFunc = blend1; outTexture.Sprite.BlendFunc = blend2; // add render textures to the layer layer.AddChild(inTexture); layer.AddChild(outTexture); // initial opacity: inTexture.Sprite.Opacity = 255; outTexture.Sprite.Opacity = 255; // create the blend action CCAction layerAction = CCSequence.FromActions ( new CCFadeTo(m_fDuration, 0), new CCCallFunc((HideOutShowIn)), new CCCallFunc((Finish)) ); //// run the blend action outTexture.Sprite.RunAction(layerAction); // add the layer (which contains our two rendertextures) to the scene AddChild(layer, 2, kSceneFade); }
//--------------------------------------------------------------------------------------------------------- // AddedToScene //--------------------------------------------------------------------------------------------------------- // protected override void AddedToScene() { base.AddedToScene(); // Use the bounds to layout the positioning of our drawable assets CCRect bounds = VisibleBoundsWorldspace; Bubbles = new CCNode(); AddChild(Bubbles); //initialize every bool in BubbleArray to false. True if there is a bubble there. for (int i = 0; i < MAX_BUBBLES_X; i++) { BubbleOccupiedArray [i] = false; } branches = ReadBranches(branchInfo); levels = ReadLevels(levelInfo); currentPlayer = new Player(); if (File.Exists(currentPlayer.PlayerDataFile)) { currentPlayer = Player.ReadData(currentPlayer); } else { currentPlayer.WriteData(currentPlayer); } // options popup optionsStd = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("gear_std.png"))); optionsStd.AnchorPoint = CCPoint.AnchorMiddle; optionsSel = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("gear_sel.png"))); optionsSel.AnchorPoint = CCPoint.AnchorMiddle; var optionPopup = new CCMenuItemImage(optionsStd, optionsSel, sender => { PauseListeners(true); Application.Paused = true; var optionsLayer = new CCLayerColor(new CCColor4B(0, 0, 0, 200)); AddChild(optionsLayer, 99999); // Add frame to layer frameSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("frame.png"))); frameSprite.AnchorPoint = CCPoint.AnchorMiddle; frameSprite.Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2); optionsLayer.AddChild(frameSprite); var highlightOnLabel = new CCLabel("Highlight Next: On", GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 2.0f }; var highlightOffLabel = new CCLabel("Highlight Next: Off", GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 2.0f }; var highlightOnMenuItem = new CCMenuItemLabel(highlightOnLabel); var highlightOffMenuItem = new CCMenuItemLabel(highlightOffLabel); highlightToggleMenuItem = new CCMenuItemToggle(ToggleHighlight, highlightOnMenuItem, highlightOffMenuItem); highlightToggleMenuItem.Enabled = currentPlayer.HighlightNextPurchased; highlightToggleMenuItem.PositionX = frameSprite.BoundingBox.MidX; highlightToggleMenuItem.PositionY = frameSprite.BoundingBox.MinY + (highlightToggleMenuItem.BoundingBox.Size.Height * 10f); highlightToggleMenuItem.SelectedIndex = (currentPlayer.IsHighlightNextActive) ? 0 : 1; var optionMenu = new CCMenu(highlightToggleMenuItem); optionMenu.AnchorPoint = CCPoint.AnchorMiddleBottom; optionMenu.Position = CCPoint.Zero; optionsLayer.AddChild(optionMenu); okLabel = new CCLabel("OK", GOTHIC_44_HD_FNT); okLabel.AnchorPoint = CCPoint.AnchorMiddle; okLabel.Scale = 2.0f; var closeItem = new CCMenuItemLabel(okLabel, closeSender => { optionsLayer.RemoveFromParent(); ResumeListeners(true); Application.Paused = false; }); closeItem.PositionX = frameSprite.BoundingBox.MidX; closeItem.PositionY = frameSprite.BoundingBox.MinY + (closeItem.BoundingBox.Size.Height * 1.5f); var closeMenu = new CCMenu(closeItem); closeMenu.AnchorPoint = CCPoint.AnchorMiddleBottom; closeMenu.Position = CCPoint.Zero; optionsLayer.AddChild(closeMenu); }); optionPopup.AnchorPoint = CCPoint.AnchorMiddle; optionPopup.Position = new CCPoint(bounds.Size.Width / 10, bounds.Size.Height / 14); var optionItemsMenu = new CCMenu(optionPopup); optionItemsMenu.AnchorPoint = CCPoint.AnchorLowerLeft; optionItemsMenu.Position = CCPoint.Zero; AddChild(optionItemsMenu); //--------------------------------------------------------------------------------------------------------- //Menu Elements //--------------------------------------------------------------------------------------------------------- newGameLabel = new CCLabel("New Game", GOTHIC_44_HD_FNT); newGameLabel.AnchorPoint = CCPoint.AnchorMiddle; newGameLabel.Scale = 2.0f; var menuItemNewGame = new CCMenuItemLabel(newGameLabel, NewGame); continueGameLabel = new CCLabel("Continue", GOTHIC_44_HD_FNT); continueGameLabel.AnchorPoint = CCPoint.AnchorMiddle; continueGameLabel.Scale = 2.0f; var menuItemContinueGame = new CCMenuItemLabel(continueGameLabel, ContinueGame); playerStatsLabel = new CCLabel("Player Stats", GOTHIC_44_HD_FNT); playerStatsLabel.AnchorPoint = CCPoint.AnchorMiddle; playerStatsLabel.Scale = 2.0f; var menuItemPlayerStats = new CCMenuItemLabel(playerStatsLabel, PlayerStats); shopLabel = new CCLabel("Shop", GOTHIC_44_HD_FNT); shopLabel.AnchorPoint = CCPoint.AnchorMiddle; shopLabel.Scale = 2.0f; var menuItemShop = new CCMenuItemLabel(shopLabel, Shop); var menu = new CCMenu(menuItemNewGame, menuItemContinueGame, menuItemPlayerStats, menuItemShop) { Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2), AnchorPoint = CCPoint.AnchorMiddle }; menu.AlignItemsVertically(150); AddChild(menu); rtLogo = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("bb_retrotek.png"))); rtLogo.AnchorPoint = CCPoint.AnchorMiddle; rtLogo.Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 14); //rtLogo.RunAction (repeatedAction); AddChild(rtLogo); title = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("bb_title.png"))); title.AnchorPoint = CCPoint.AnchorMiddle; title.Position = new CCPoint(bounds.Size.Width / 2, (bounds.Size.Height / 7) * 6); title.RunAction(repeatedAction); AddChild(title); //if (currentPlayer.LastLevelCompleted < 0) { if (currentPlayer.BranchProgression[1].LastLevelCompleted < 0) { menuItemNewGame.Enabled = true; menuItemContinueGame.Enabled = false; menuItemPlayerStats.Enabled = false; } else { menuItemNewGame.Enabled = true; menuItemContinueGame.Enabled = true; menuItemPlayerStats.Enabled = true; } Schedule(_ => CheckForFadedBubbles()); }
//--------------------------------------------------------------------------------------------------------- // PlayerDelete //--------------------------------------------------------------------------------------------------------- // Deletes player information //--------------------------------------------------------------------------------------------------------- void PlayerDelete(object stuff) { PauseListeners(true); Application.Paused = true; var playerResetLayer = new CCLayerColor(new CCColor4B(0, 0, 0, 230)); AddChild(playerResetLayer, 99999); // Add frame to layer var frameSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("frame.png"))); frameSprite.AnchorPoint = CCPoint.AnchorMiddle; frameSprite.Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2); playerResetLayer.AddChild(frameSprite); string playerName = string.Empty; var sentMenuItem = (CCMenuItemImage)stuff; var playerSlotString = sentMenuItem.UserData.ToString(); if (playerSlotString == "Slot1") { playerName = player1.Name; } else if (playerSlotString == "Slot2") { playerName = player1.Name; } else if (playerSlotString == "Slot3") { playerName = player1.Name; } var playerNameLabel = new CCLabel(playerName, GOTHIC_56_WHITE_HD_FNT); playerNameLabel.AnchorPoint = CCPoint.AnchorMiddle; playerNameLabel.Scale = 2; playerNameLabel.PositionX = frameSprite.BoundingBox.Center.X; playerNameLabel.PositionY = frameSprite.BoundingBox.MaxY - 200; playerNameLabel.HorizontalAlignment = CCTextAlignment.Center; playerResetLayer.AddChild(playerNameLabel); var newGameWarning = new CCLabel("This will erase your current progress!\n\n\nProceed?", GOTHIC_56_WHITE_FNT); newGameWarning.AnchorPoint = CCPoint.AnchorMiddle; newGameWarning.Scale = 1.5f; newGameWarning.Position = new CCPoint(frameSprite.BoundingBox.Center); newGameWarning.HorizontalAlignment = CCTextAlignment.Center; playerResetLayer.AddChild(newGameWarning); var okLabel = new CCLabel("OK", GOTHIC_44_HD_FNT); okLabel.AnchorPoint = CCPoint.AnchorMiddle; okLabel.Scale = 1.5f; var cancelLabel = new CCLabel("Cancel", GOTHIC_44_HD_FNT); cancelLabel.AnchorPoint = CCPoint.AnchorMiddle; cancelLabel.Scale = 1.5f; var okItem = new CCMenuItemLabel(okLabel, okSender => { playerResetLayer.RemoveFromParent(); ResumeListeners(true); Application.Paused = false; if (playerSlotString == "Slot1") { player1 = new Player(PlayerSlot.slot1); player1.WriteData(player1); } else if (playerSlotString == "Slot2") { player2 = new Player(PlayerSlot.slot2); player2.WriteData(player2); } else if (playerSlotString == "Slot3") { player3 = new Player(PlayerSlot.slot3); player3.WriteData(player3); } UpdateUI(); }); okItem.Position = bounds.Center; var cancelItem = new CCMenuItemLabel(cancelLabel, cancelSender => { playerResetLayer.RemoveFromParent(); ResumeListeners(true); Application.Paused = false; }); cancelItem.Position = bounds.Center; var closeMenu = new CCMenu(okItem, cancelItem); closeMenu.AlignItemsHorizontally(50); closeMenu.AnchorPoint = CCPoint.AnchorMiddleBottom; closeMenu.Position = new CCPoint(bounds.Size.Width / 2, frameSprite.BoundingBox.MinY + (okLabel.BoundingBox.Size.Height * 2.5f)); playerResetLayer.AddChild(closeMenu); }
//--------------------------------------------------------------------------------------------------------- // PlayerInfo //--------------------------------------------------------------------------------------------------------- // Displays the player information popup // TODO: modify the information shown to match player class attributes //--------------------------------------------------------------------------------------------------------- void PlayerInfo(object stuff) { Player currentPlayer; var sentMenuItem = (CCMenuItemImage)stuff; var playerSlotString = sentMenuItem.UserData.ToString(); if (playerSlotString == "Slot1") { currentPlayer = player1; } else if (playerSlotString == "Slot2") { currentPlayer = player2; } else if (playerSlotString == "Slot3") { currentPlayer = player3; } PauseListeners(true); Application.Paused = true; var playerStatsLayer = new CCLayerColor(new CCColor4B(0, 0, 0, 230)); AddChild(playerStatsLayer, 99999); // Add frame to layer var frameSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("frame.png"))); frameSprite.AnchorPoint = CCPoint.AnchorMiddle; frameSprite.Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2); frameSprite.ScaleY = 1.3f; playerStatsLayer.AddChild(frameSprite); var titleLabel = new CCLabel("Player Stats", GOTHIC_56_WHITE_HD_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1f }; var titleMenuItem = new CCMenuItemLabel(titleLabel); var playerNameLabel = new CCLabel(string.Format("Player Name: {0}", currentPlayer.Name), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var playerNameMenuItem = new CCMenuItemLabel(playerNameLabel); //var lastLevelLabel = new CCLabel ((currentPlayer.LastLevelCompleted == -1) ? "Last Level Completed: Not Started Yet" : string.Format ("Last Level Completed: {0}", currentPlayer.LastLevelCompleted), GOTHIC_56_WHITE_FNT) { // TODO: instead of last level competed, change to report next level to be played var lastLevelLabel = new CCLabel((currentPlayer.BranchProgression[1].BranchState == CompletionState.notStarted) ? "Last Level Completed: Not Started Yet" : string.Format("Last Level Completed: {0}", currentPlayer.BranchProgression[1].LastLevelCompleted), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var lastLevelMenuItem = new CCMenuItemLabel(lastLevelLabel); var coinsLabel = new CCLabel(string.Format("Coins: {0}", currentPlayer.Coins), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var coinsMenuItem = new CCMenuItemLabel(coinsLabel); var highScoreLabel = new CCLabel(string.Format("High Score: {0}", currentPlayer.TotalScores), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var highScoreMenuItem = new CCMenuItemLabel(highScoreLabel); var tapStrengthLabel = new CCLabel(string.Format("Tap Strength: {0}", currentPlayer.PersistentTapStrength), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var tapStrengthMenuItem = new CCMenuItemLabel(tapStrengthLabel); var percentChanceNextSeqLabel = new CCLabel(string.Format("Next in Sequence Luck: {0}%", currentPlayer.ChanceToRollNextSeq), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var percentChanceNextSeqMenuItem = new CCMenuItemLabel(percentChanceNextSeqLabel); var percentChanceBonusLabel = new CCLabel(string.Format("Bonus Bubble Luck: {0}%", currentPlayer.ChanceToRollBonus), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var percentChanceBonusMenuItem = new CCMenuItemLabel(percentChanceBonusLabel); var timeBonusLabel = new CCLabel(string.Format("Additional Level Time: {0} Seconds", currentPlayer.PersistentTimeBonus), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var timeBonusMenuItem = new CCMenuItemLabel(timeBonusLabel); var time2xBonusLabel = new CCLabel(string.Format("2x Bonus Timer Extra: {0} Seconds", currentPlayer.Persistent2xTimeBonus), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var time2xBonusMenuItem = new CCMenuItemLabel(time2xBonusLabel); var time3xBonusLabel = new CCLabel(string.Format("3x Bonus Timer Extra: {0} Seconds", currentPlayer.Persistent3xTimeBonus), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.0f }; var time3xBonusMenuItem = new CCMenuItemLabel(time3xBonusLabel); var highlightNextAvailableLabel = new CCLabel("Highlight Next Sequence Bubble: " + ((currentPlayer.HighlightNextPurchased) ? "Yes" : "No"), GOTHIC_56_WHITE_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = Scale = 1.0f }; var highlightNextMenuItem = new CCMenuItemLabel(highlightNextAvailableLabel); var okButtonLabel = new CCLabel("OK", GOTHIC_30_HD_FNT) { AnchorPoint = AnchorPoint = CCPoint.AnchorMiddle, Scale = 2.0f }; var okButtonMenuItem = new CCMenuItemLabel(okButtonLabel, okSender => { playerStatsLayer.RemoveFromParent(); ResumeListeners(true); Application.Paused = false; }); var playerStatsMenu = new CCMenu(titleMenuItem, playerNameMenuItem, lastLevelMenuItem, coinsMenuItem, highScoreMenuItem, tapStrengthMenuItem, percentChanceNextSeqMenuItem, percentChanceBonusMenuItem, timeBonusMenuItem, time2xBonusMenuItem, time3xBonusMenuItem, highlightNextMenuItem, okButtonMenuItem); playerStatsMenu.AnchorPoint = CCPoint.AnchorMiddle; playerStatsMenu.Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2); playerStatsMenu.AlignItemsVertically(40); playerStatsLayer.AddChild(playerStatsMenu); }
public override void OnEnter() { base.OnEnter(); CCRect visibleBounds = VisibleBoundsWorldspace; var origin = Layer.VisibleBoundsWorldspace.Origin; var size = Layer.VisibleBoundsWorldspace.Size; var sprite1 = new TouchableSprite(); var texture = CCTextureCache.SharedTextureCache.AddImage("Images/CyanSquare.png"); sprite1.Texture = texture; sprite1.Position = origin + new CCPoint(size.Width / 2, size.Height / 2) + new CCPoint(-80, 80); AddChild(sprite1, -10); var sprite2 = new TouchableSprite(); texture = CCTextureCache.SharedTextureCache.AddImage("Images/MagentaSquare.png"); sprite2.Texture = texture; sprite2.Position = origin + new CCPoint(size.Width / 2, size.Height / 2); AddChild(sprite2, -20); var sprite3 = new TouchableSprite(); texture = CCTextureCache.SharedTextureCache.AddImage("Images/YellowSquare.png"); sprite3.Texture = texture; sprite3.Position = CCPoint.Zero; sprite2.AddChild(sprite3, -1); CCMenuItemFont.FontSize = 20; CCMenuItemFont.FontName = "arial"; var popup = new CCMenuItemFont("Popup", (sender) => { this.PauseListeners(true); var colorLayer = new CCLayerColor(new CCColor4B(0, 0, 255, 100)); AddChild(colorLayer, 99999); var closeItem = new CCMenuItemFont("close", (closeSender) => { colorLayer.RemoveFromParent(); this.ResumeListeners(true); }); closeItem.Position = visibleBounds.Center; var closeMenu = new CCMenu(closeItem); closeMenu.AnchorPoint = CCPoint.AnchorLowerLeft; closeMenu.Position = CCPoint.Zero; colorLayer.AddChild(closeMenu); }); popup.AnchorPoint = CCPoint.AnchorMiddleRight; popup.Position = new CCPoint(visibleBounds.Origin.X + visibleBounds.Size.Width, visibleBounds.Origin.Y + visibleBounds.Size.Height / 2); var menu = new CCMenu(popup); menu.AnchorPoint = CCPoint.AnchorLowerLeft; menu.Position = CCPoint.Zero; AddChild(menu); }