public TextLayer() : base() { Color = new CCColor3B(32, 128, 32); Opacity = 255; BaseNode = new CCNodeGrid(); var effect = CurrentAction; BaseNode.RunAction(effect); AddChild(BaseNode, 0, EffectTestScene.kTagBackground); var bg = new CCSprite(TestResource.s_back3); BaseNode.AddChild(bg, 0); var Kathia = new CCSprite(TestResource.s_pPathSister2); BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia); var sc = new CCScaleBy(2, 5); var sc_back = sc.Reverse(); Kathia.RunAction(new CCRepeatForever(sc, sc_back)); var Tamara = new CCSprite(TestResource.s_pPathSister1); BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara); var sc2 = new CCScaleBy(2, 5); var sc2_back = sc2.Reverse(); Tamara.RunAction(new CCRepeatForever(sc2, sc2_back)); }
public CCMotionStreak(float fade, float minSegIn, float strokeIn, CCColor3B color, CCTexture2D texture) { streakRenderCommand = new CCCustomCommand(RenderMotionStreak); AnchorPoint = CCPoint.Zero; IgnoreAnchorPointForPosition = true; StartingPositionInitialized = false; FastMode = true; Texture = texture; Color = color; stroke = strokeIn; BlendFunc = CCBlendFunc.NonPremultiplied; minSeg = (minSegIn == -1.0f) ? stroke / 5.0f : minSegIn; minSeg *= minSeg; fadeDelta = 1.0f / fade; maxPoints = (int) (fade * 60.0f) + 2; pointState = new float[maxPoints]; pointVertexes = new CCPoint[maxPoints]; vertices = new CCV3F_C4B_T2F[(maxPoints + 1) * 2]; Schedule(); }
public AlignmentPanel(CCSize size, CCColor4B color) { Color = new CCColor3B(color); Opacity = color.A; //AnchorPoint = CCPoint.AnchorMiddle; ContentSize = size; }
public IntroLayer() { // setup our color for the background Color = new CCColor3B(CCColor4B.Red); Opacity = 0; renderCommand = new CCCustomCommand(RenderUI); }
/// <summary> /// Initializes a new instance of the <see cref="Client.Common.Views.HUD.PopulationResource"/> class. /// </summary> /// <param name="fileName">PNG file name.</param> /// <param name="color">Fill color.</param> public PopulationResource(string fileName, CCColor3B color) : base() { m_background = new Button( fileName, fileName, OnTouched); AddChild(m_background); m_background.Sprite.Opacity = 100; // picture source // <div>Icons made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> // from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> // is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" // title="Creative Commons BY 3.0">CC BY 3.0</a></div> m_progress = new CCProgressTimer(fileName); m_progress.Color = color; m_progress.Type = CCProgressTimerType.Bar; m_progress.BarChangeRate = new CCPoint(0.0f, 1.0f); m_progress.Midpoint = new CCPoint(0.0f, 0.0f); m_progress.PositionX = m_background.AnchorPoint.X; m_progress.PositionY = m_background.AnchorPoint.Y; m_background.AddChild(m_progress); Schedule(ShowRessource); }
public CCMotionStreak(float fade, float minSegIn, float strokeIn, CCColor3B color, CCTexture2D texture) { streakRenderCommand = new CCCustomCommand(RenderMotionStreak); AnchorPoint = CCPoint.Zero; IgnoreAnchorPointForPosition = true; StartingPositionInitialized = false; FastMode = true; Texture = texture; Color = color; stroke = strokeIn; BlendFunc = CCBlendFunc.NonPremultiplied; minSeg = (minSegIn == -1.0f) ? stroke / 5.0f : minSegIn; minSeg *= minSeg; fadeDelta = 1.0f / fade; maxPoints = (int)(fade * 60.0f) + 2; pointState = new float[maxPoints]; pointVertexes = new CCPoint[maxPoints]; vertices = new CCV3F_C4B_T2F[(maxPoints + 1) * 2]; Schedule(); }
public GameLayer() { var touchListener = new CCEventListenerTouchAllAtOnce (); touchListener.OnTouchesEnded = OnTouchesEnded; AddEventListener (touchListener, this); Color = new CCColor3B (CCColor4B.White); Opacity = 255; visibleBananas = new List<CCSprite> (); hitBananas = new List<CCSprite> (); // batch node for physics balls ballsBatch = new CCSpriteBatchNode ("balls", 100); ballTexture = ballsBatch.Texture; AddChild (ballsBatch, 1, 1); AddGrass (); AddSun (); AddMonkey (); StartScheduling(); CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic ("Sounds/backgroundMusic", true); }
public void openTest(string pCCBFileName, string pCCNodeName, CCNodeLoader pCCNodeLoader) { /* Create an autorelease CCNodeLoaderLibrary. */ CCNodeLoaderLibrary ccNodeLoaderLibrary = new CCNodeLoaderLibrary(); ccNodeLoaderLibrary.RegisterCCNodeLoader("TestHeaderLayer", new Loader<TestHeaderLayer>()); if (pCCNodeName != null && pCCNodeLoader != null) { ccNodeLoaderLibrary.RegisterCCNodeLoader(pCCNodeName, pCCNodeLoader); } /* Create an autorelease CCBReader. */ var ccbReader = new CCBReader(ccNodeLoaderLibrary); /* Read a ccbi file. */ // Load the scene from the ccbi-file, setting this class as // the owner will cause lblTestTitle to be set by the CCBReader. // lblTestTitle is in the TestHeader.ccbi, which is referenced // from each of the test scenes. CCNode node = ccbReader.ReadNodeGraphFromFile(pCCBFileName, this); mTestTitleLabelTTF.Text = (pCCBFileName); CCScene scene = new CCScene(Scene); scene.AddChild(node); /* Push the new scene with a fancy transition. */ CCColor3B transitionColor = new CCColor3B(); transitionColor.R = 0; transitionColor.G = 0; transitionColor.B = 0; Scene.Director.PushScene(new CCTransitionFade(0.5f, scene, transitionColor)); }
void SetupCCLayerColor(CCColor4B color) { DisplayedColor = RealColor = new CCColor3B(color.R, color.G, color.B); DisplayedOpacity = RealOpacity = color.A; BlendFunc = CCBlendFunc.NonPremultiplied; UpdateColor(); }
/// <summary> /// creates a CCLayer with color, width and height in Points /// </summary> public CCLayerColor(CCCamera camera, CCColor4B color) : base(camera) { DisplayedColor = RealColor = new CCColor3B(color.R, color.G, color.B); DisplayedOpacity = RealOpacity = color.A; BlendFunc = CCBlendFunc.NonPremultiplied; UpdateColor(); }
public static CCNode CreateLabel(string text, float size, CCColor3B color, CCColor3B shadowColor) { var node = new CCNode () { AnchorPoint = CCPoint.AnchorMiddle, }; size *= 1.2f; var lbl = new CCLabel(text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont) { Color = color, AnchorPoint = CCPoint.AnchorMiddle, }; lbl.LabelFormat.Alignment = CCTextAlignment.Center; node.ContentSize = lbl.ScaledContentSize; lbl.Position = node.ContentSize.Center; if (shadowColor != CCColor3B.Magenta) { node.ContentSize = lbl.ContentSize + 2; var shadowLbl = new CCLabel (text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont) { Color = shadowColor, AnchorPoint = CCPoint.AnchorMiddle, Position = new CCPoint(node.ContentSize.Center.X + 2, node.ContentSize.Center.Y - 2) }; shadowLbl.LabelFormat.Alignment = CCTextAlignment.Center; node.AddChild (shadowLbl); } node.AddChild (lbl); return node; }
public LabelSFTextureView() { Color = new CCColor3B(128, 128, 128); Opacity = 255; }
public Background(CCSize size, CCColor4B color) { Color = new CCColor3B(color); Opacity = color.A; AnchorPoint = CCPoint.AnchorMiddle; ContentSize = size; }
void updateColors() { if (Text == placeHolderText) { if (Color.R != PlaceHolderTextColor.R || Color.G != PlaceHolderTextColor.G || Color.B != PlaceHolderTextColor.B || Opacity != PlaceHolderTextColor.A) { Color = new CCColor3B(placeholderTextColor); Opacity = placeholderTextColor.A; } } else { if (Color.R != defaultTextColor.R || Color.G != defaultTextColor.G || Color.B != defaultTextColor.B || Opacity != defaultTextColor.A) { Color = new CCColor3B(defaultTextColor); Opacity = defaultTextColor.A; } } }
public GameOverLayer (int score) { var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = (touches, ccevent) => CCDirector.SharedDirector.ReplaceScene (GameLayer.Scene); EventDispatcher.AddEventListener(touchListener, this); string scoreMessage = String.Format ("Game Over. You collected {0} bananas!", score); var scoreLabel = new CCLabelTtf (scoreMessage, "MarkerFelt", 22) { Position = new CCPoint( CCDirector.SharedDirector.WinSize.Center.X, CCDirector.SharedDirector.WinSize.Center.Y + 50), Color = new CCColor3B (CCColor4B.Yellow), HorizontalAlignment = CCTextAlignment.Center, VerticalAlignment = CCVerticalTextAlignment.Center, Dimensions = ContentSize }; AddChild (scoreLabel); var playAgainLabel = new CCLabelTtf ("Tap to Play Again", "MarkerFelt", 22) { Position = CCDirector.SharedDirector.WinSize.Center, Color = new CCColor3B (CCColor4B.Green), HorizontalAlignment = CCTextAlignment.Center, VerticalAlignment = CCVerticalTextAlignment.Center, Dimensions = ContentSize }; AddChild (playAgainLabel); Color = new CCColor3B (CCColor4B.Black); Opacity = 255; }
public GameLayer () { var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = OnTouchesEnded; EventDispatcher.AddEventListener(touchListener, this); Color = new CCColor3B (CCColor4B.White); Opacity = 255; visibleBananas = new List<CCSprite> (); hitBananas = new List<CCSprite> (); monkey = new CCSprite ("Monkey"); monkey.Position = CCDirector.SharedDirector.WinSize.Center; AddChild (monkey); Schedule ((t) => { visibleBananas.Add (AddBanana ()); dt += t; if(ShouldEndGame ()){ var gameOverScene = GameOverLayer.SceneWithScore(hitBananas.Count); CCTransitionFadeDown transitionToGameOver = new CCTransitionFadeDown(1.0f, gameOverScene); CCDirector.SharedDirector.ReplaceScene (transitionToGameOver); } }, 1.0f); Schedule ((t) => { CheckCollision (); }); }
protected CCMenuItemLabelBase(Action<object> target = null) : base(target) { originalScale = new CCPoint(1.0f, 1.0f); ColorBackup = CCColor3B.White; DisabledColor = new CCColor3B(126, 126, 126); IsColorCascaded = true; IsOpacityCascaded = true; }
protected CCMenuItemLabelBase(Action <object> target = null) : base(target) { originalScale = new CCPoint(1.0f, 1.0f); ColorBackup = CCColor3B.White; DisabledColor = new CCColor3B(126, 126, 126); IsColorCascaded = true; IsOpacityCascaded = true; }
/// <summary> /// /// </summary> /// <param name="message"></param> /// <param name="size"></param> /// <param name="color"></param> public LoadingLabel(string message, CCColor3B color) : base(message, color) { Color = color; m_message = message; AnchorPoint = CCPoint.AnchorUpperLeft; Schedule(UpdateLoading, INTERVAL); }
void SetupCCLayerColor(CCColor4B?color = null) { var setupColor = (color.HasValue) ? color.Value : CCColor4B.Transparent; DisplayedColor = RealColor = new CCColor3B(setupColor.R, setupColor.G, setupColor.B); DisplayedOpacity = RealOpacity = setupColor.A; BlendFunc = CCBlendFunc.NonPremultiplied; UpdateColor(); }
public void TintWithColor(CCColor3B colors) { Color = colors; for (int i = 0; i < numOfPoints * 2; i++) { vertices[i].Colors = new CCColor4B(colors.R, colors.G, colors.B, 255); } }
public LabelFNTGlyphDesigner() { Color = new CCColor3B(128, 128, 128); Opacity = 255; // CCLabelBMFont label1 = new CCLabel ("Testing Glyph Designer", "fonts/futura-48.fnt"); AddChild(label1); }
public LabelSystemFont168() { Color = new CCColor3B(200, 191, 231); Opacity = 255; fadeOut = new CCFadeOutBLTiles(1f, new CCGridSize(10, 10)); Schedule(StressIt, 2.0f); }
/// <summary> /// Creates a full-screen CCLayer with a gradient between start and end in the direction of v. /// </summary> public CCLayerGradient(CCColor4B start, CCColor4B end, CCPoint gradientDirection) : base(new CCColor4B(start.R, start.G, start.B, 255)) { EndColor = new CCColor3B(end.R, end.G, end.B); StartOpacity = start.A; EndOpacity = end.A; IsCompressedInterpolation = true; alongVector = gradientDirection; }
public LabelFNTBounds () { Color = new CCColor3B(128, 128, 128); Opacity = 255; label = new CCLabel("Testing Glyph Designer", "fonts/boundsTestFont.fnt"); label.LabelFormat.Alignment = CCTextAlignment.Center; AddChild(label); drawNode = new CCDrawNode(); AddChild(drawNode); }
public IntroLayer() { // create and initialize a Label label = new CCLabelTtf("Hello CocosSharp", "MarkerFelt", 22); label.AnchorPoint = CCPoint.AnchorMiddle; // add the label as a child to this Layer AddChild(label); // setup our color for the background Color = new CCColor3B(CCColor4B.Blue); Opacity = 255; }
public GameOverLayer(int score) { var touchListener = new CCEventListenerTouchAllAtOnce (); touchListener.OnTouchesEnded = (touches, ccevent) => Window.DefaultDirector.ReplaceScene (GameLayer.GameScene (Window)); AddEventListener (touchListener, this); scoreMessage = String.Format ("Game Over. You collected {0} bananas!", score); Color = new CCColor3B (CCColor4B.Black); Opacity = 255; }
public LabelFNTLineHeightTest() { Color = new CCColor3B(200, 191, 231); Opacity = 255; // Register Touch Event var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesBegan = onTouchesBegan; touchListener.OnTouchesMoved = onTouchesMoved; touchListener.OnTouchesEnded = onTouchesEnded; AddEventListener(touchListener); }
public virtual bool onTextFieldInsertText(CCTextFieldTTF pSender, string text, int nLen) { // if insert enter, treat as default to detach with ime if ("\n" == text) { return(false); } // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore. if (pSender.Text.Length >= m_nCharLimit) { return(true); } // create a insert text sprite and do some action CCLabelTtf label = new CCLabelTtf(text, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE); this.AddChild(label); CCColor3B color = new CCColor3B { R = 226, G = 121, B = 7 }; label.Color = color; // move the sprite from top to position CCPoint endPos = pSender.Position; if (pSender.Text.Length > 0) { endPos.X += pSender.ContentSize.Width / 2; } CCSize inputTextSize = label.ContentSize; CCPoint beginPos = new CCPoint(endPos.X, Layer.VisibleBoundsWorldspace.Size.Height - inputTextSize.Height * 2); float duration = 0.5f; label.Position = beginPos; label.Scale = 8; CCAction seq = new CCSequence( new CCSpawn( new CCMoveTo(duration, endPos), new CCScaleTo(duration, 1), new CCFadeOut(duration)), new CCCallFuncN(callbackRemoveNodeWhenDidAction)); label.RunAction(seq); return(false); }
public override void UpdateDisplayedColor(CCColor3B parentColor) { base.UpdateDisplayedColor(parentColor); if (scale9Image != null && scale9Image.Children != null) { foreach (CCNode child in Children) { var node = child; if (node != null) { node.UpdateDisplayedColor(parentColor); } } } }
/** * Sets the color of the title to use for the specified state. * * @param color The color of the title to use for the specified state. * @param state The state that uses the specified color. The values are described * in "CCControlState". */ public virtual void SetTitleColorForState(CCColor3B color, CCControlState state) { if (titleColorDispatchTable.ContainsKey(state)) { titleColorDispatchTable.Remove(state); } titleColorDispatchTable.Add(state, color); // If the current state if equal to the given state we update the layout if (State == state) { NeedsLayout(); } }
public GameLayer () { var touchListener = new CCEventListenerTouchAllAtOnce (); touchListener.OnTouchesEnded = OnTouchesEnded; AddEventListener (touchListener, this); Color = new CCColor3B (CCColor4B.White); Opacity = 255; visibleBananas = new List<CCSprite> (); hitBananas = new List<CCSprite> (); // batch node for physics balls ballsBatch = new CCSpriteBatchNode ("balls", 100); ballTexture = ballsBatch.Texture; AddChild (ballsBatch, 1, 1); AddGrass (); AddSun (); AddMonkey (); Schedule (t => { visibleBananas.Add (AddBanana ()); elapsedTime += t; if (ShouldEndGame ()) { EndGame (); } AddBall (); }, 1.0f); Schedule (t => CheckCollision ()); Schedule (t => { world.Step (t, 8, 1); foreach (CCPhysicsSprite sprite in ballsBatch.Children) { if (sprite.Visible && sprite.PhysicsBody.Position.x < 0f || sprite.PhysicsBody.Position.x * PTM_RATIO > ContentSize.Width) { //or should it be Layer.VisibleBoundsWorldspace.Size.Width world.DestroyBody (sprite.PhysicsBody); sprite.Visible = false; sprite.RemoveFromParent (); } else { sprite.UpdateTransformedSpriteTextureQuads (); } } }); }
public IntroLayer () { // create and initialize a Label var label = new CCLabelTtf("Hello CocosSharp", "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 (CCColor4B.Blue); Opacity = 255; }
public LabelSystemFontColorAndOpacity() { m_time = 0; Color = new CCColor3B(128, 128, 128); Opacity = 255; label1 = new CCLabel("Label FadeOut/FadeIn", "fonts/Marker Felt.ttf", 40, CCLabelFormat.SystemFont) { Color = CCColor3B.Orange, // testing anchors AnchorPoint = CCPoint.AnchorLowerLeft }; AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); var fade = new CCFadeOut (1.0f); var fade_in = fade.Reverse(); label1.RepeatForever ( fade, fade_in); label2 = new CCLabel("Label TintTo", "fonts/MorrisRoman-Black.ttf", 40, CCLabelFormat.SystemFont) { Color = CCColor3B.Red, // testing anchors AnchorPoint = CCPoint.AnchorMiddle }; AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.RepeatForever( new CCTintTo (1, 255, 0, 0), new CCTintTo (1, 0, 255, 0), new CCTintTo (1, 0, 0, 255)); label3 = new CCLabel("Label\nPlain\nBlue", "Helvetica", 40, CCLabelFormat.SystemFont) { Color = CCColor3B.Blue, Opacity = 128, // testing anchors AnchorPoint = CCPoint.AnchorUpperRight }; AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); //base.Schedule(step); }
public GameStartLayer () { var touchListener = new CCEventListenerTouchAllAtOnce (); touchListener.OnTouchesEnded = (touches, ccevent) => CCDirector.SharedDirector.ReplaceScene (GameLayer.Scene); EventDispatcher.AddEventListener (touchListener, this); var label = new CCLabelTtf ("Tap Screen to Go Bananas!", "MarkerFelt", 22) { Position = CCDirector.SharedDirector.WinSize.Center, Color = new CCColor3B (CCColor4B.Blue), HorizontalAlignment = CCTextAlignment.Center, VerticalAlignment = CCVerticalTextAlignment.Center, Dimensions = ContentSize }; AddChild (label); Color = new CCColor3B (CCColor4B.AliceBlue); Opacity = 255; }
public LabelFNTColorAndOpacity() { m_time = 0; Color = new CCColor3B(128, 128, 128); Opacity = 255; label1 = new CCLabel("Label1", "fonts/bitmapFontTest2.fnt"); // testing anchors label1.AnchorPoint = CCPoint.AnchorLowerLeft; AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); var fade = new CCFadeOut (1.0f); var fade_in = fade.Reverse(); label1.RepeatForever ( fade, fade_in); // VERY IMPORTANT // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image) // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected label2 = new CCLabel("Label2", "fonts/bitmapFontTest2.fnt"); // testing anchors label2.AnchorPoint = CCPoint.AnchorMiddle; label2.Color = CCColor3B.Red; AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.RepeatForever( new CCTintTo (1, 255, 0, 0), new CCTintTo (1, 0, 255, 0), new CCTintTo (1, 0, 0, 255)); label3 = new CCLabel("Label3", "fonts/bitmapFontTest2.fnt"); // testing anchors label3.AnchorPoint = CCPoint.AnchorUpperRight; AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); base.Schedule(step); }
public LabelSystemFontRenderTexture() { Color = new CCColor3B(200, 191, 231); Opacity = 255; label1 = new CCLabel("Visit Rendering", "fonts/MorrisRoman-Black.ttf", 30, CCLabelFormat.SystemFont) { Color = CCColor3B.Orange, AnchorPoint = CCPoint.AnchorMiddleLeft, Dimensions = size, }; label1.LabelFormat.Alignment = CCTextAlignment.Center; txtLabel = new CCRenderTexture (size, size); txtLabel.BeginWithClear (CCColor4B.AliceBlue); label1.Visit (); txtLabel.End (); AddChild(txtLabel.Sprite); }
private void InitCCControlButton(CCNode node, CCNode backgroundSprite) { Debug.Assert(node != null, "Label must not be nil."); var label = node as ICCTextContainer; var rgbaLabel = node; Debug.Assert(backgroundSprite != null, "Background sprite must not be nil."); Debug.Assert(label != null || rgbaLabel != null || backgroundSprite != null); parentInited = true; // Initialize the button state tables titleDispatchTable = new Dictionary <CCControlState, string>(); titleColorDispatchTable = new Dictionary <CCControlState, CCColor3B>(); titleLabelDispatchTable = new Dictionary <CCControlState, CCNode>(); backgroundSpriteDispatchTable = new Dictionary <CCControlState, CCNode>(); // Register Touch Event var touchListener = new CCEventListenerTouchOneByOne(); touchListener.IsSwallowTouches = true; touchListener.OnTouchBegan = onTouchBegan; touchListener.OnTouchMoved = onTouchMoved; touchListener.OnTouchEnded = onTouchEnded; touchListener.OnTouchCancelled = onTouchCancelled; AddEventListener(touchListener); isPushed = false; zoomOnTouchDown = true; currentTitle = null; // Adjust the background image by default IsAdjustBackgroundImage = true; PreferredSize = CCSize.Zero; // Zooming button by default zoomOnTouchDown = true; // Set the default anchor point IgnoreAnchorPointForPosition = false; AnchorPoint = new CCPoint(0.5f, 0.5f); // Set the nodes TitleLabel = node; BackgroundSprite = backgroundSprite; // Set the default color and opacity Color = new CCColor3B(255, 255, 255); Opacity = 255; IsColorModifiedByOpacity = true; // Initialize the dispatch table string tempString = label.Text; //tempString->autorelease(); SetTitleForState(tempString, CCControlState.Normal); SetTitleColorForState(rgbaLabel.Color, CCControlState.Normal); SetTitleLabelForState(node, CCControlState.Normal); SetBackgroundSpriteForState(backgroundSprite, CCControlState.Normal); LabelAnchorPoint = new CCPoint(0.5f, 0.5f); NeedsLayout(); }
public CCMotionStreak(float fade, float minSeg, float stroke, CCColor3B color, string path) : this(fade, minSeg, stroke, color, CCTextureCache.SharedTextureCache.AddImage(path)) { }
/// <summary> /// creates a CCLayer with color, width and height in Points /// </summary> public CCLayerColor (CCCamera camera, CCColor4B color) : base(camera) { DisplayedColor = RealColor = new CCColor3B(color.R, color.G, color.B); DisplayedOpacity = RealOpacity = color.A; BlendFunc = CCBlendFunc.NonPremultiplied; UpdateColor(); }
public override void OnEnter() { base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size; Color = new CCColor3B(0, 0, 0); RemoveChild(Background, true); Background = null; var system = new CCParticleSystemQuad("Particles/SpinningPeas"); system.Texture = (CCTextureCache.SharedTextureCache.AddImage ("Images/particles")); system.TextureRect = new CCRect(0, 0, 32, 32); AddChild(system, 10); Emitter = system; index = 0; Schedule(UpdateQuads, 2.0f); }
public override void OnEnter() { base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size; Color = new CCColor3B(0, 0, 0); RemoveChild(Background, true); Background = null; Emitter = new CCParticleSystemQuad(100, CCEmitterMode.Radius); AddChild(Emitter, 10); Emitter.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); // duration Emitter.Duration = CCParticleSystem.ParticleDurationInfinity; // radius mode: start and end radius in pixels Emitter.StartRadius = (50); Emitter.StartRadiusVar = (0); Emitter.EndRadius = (CCParticleSystem.ParticleStartRadiusEqualToEndRadius); Emitter.EndRadiusVar = (0); // radius mode: degrees per second Emitter.RotatePerSecond = (0); Emitter.RotatePerSecondVar = (0); // angle Emitter.Angle = 90; Emitter.AngleVar = 0; // emitter position CCSize size = WindowSize; Emitter.Position = new CCPoint(size.Width / 2, size.Height / 2); Emitter.PositionVar = new CCPoint(0, 0); // life of particles Emitter.Life = 5; Emitter.LifeVar = 0; // spin of particles Emitter.StartSpin = 0; Emitter.StartSpinVar = 0; Emitter.EndSpin = 0; Emitter.EndSpinVar = 0; // color of particles var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); Emitter.StartColor = startColor; var startColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); Emitter.StartColorVar = startColorVar; var endColor = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); Emitter.EndColor = endColor; var endColorVar = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); Emitter.EndColorVar = endColorVar; // size, in pixels Emitter.StartSize = 16; Emitter.StartSizeVar = 0; Emitter.EndSize = CCParticleSystem.ParticleStartSizeEqualToEndSize; // emits per second Emitter.EmissionRate = Emitter.TotalParticles / Emitter.Life; // additive Emitter.BlendAdditive = false; CCRotateBy rot = new CCRotateBy (16, 360); Emitter.RunAction(new CCRepeatForever (rot)); }
public override void OnEnter() { base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size; Color = new CCColor3B(0, 0, 0); RemoveChild(Background, true); Background = null; string filename = "Particles/" + title; CCParticleSystemConfig config; if (particleConfigManager.ContainsKey (filename)) config = particleConfigManager [filename]; else { config = new CCParticleSystemConfig(filename, null); particleConfigManager.Add (filename, config); } Emitter = new CCParticleSystemQuad(config); AddChild(Emitter, 10); Emitter.BlendAdditive = true; SetEmitterPosition(); }
public CCColor3BWapper(CCColor3B xcolor) { color = xcolor; }
public AlignmentPanel(CCColor4B color) { Color = new CCColor3B(color); Opacity = color.A; //AnchorPoint = CCPoint.AnchorLowerLeft; }
private CCBKeyframe ReadKeyframe(CCBPropertyType type) { var keyframe = new CCBKeyframe(); keyframe.Time = ReadFloat(); var easingType = (CCBEasingType)ReadInt(false); float easingOpt = 0; object value = null; if (easingType == CCBEasingType.CubicIn || easingType == CCBEasingType.CubicOut || easingType == CCBEasingType.CubicInOut || easingType == CCBEasingType.ElasticIn || easingType == CCBEasingType.ElasticOut || easingType == CCBEasingType.ElasticInOut) { easingOpt = ReadFloat(); } keyframe.EasingType = easingType; keyframe.EasingOpt = easingOpt; if (type == CCBPropertyType.Check) { value = new CCBValue(ReadBool()); } else if (type == CCBPropertyType.Byte) { value = new CCBValue(ReadByte()); } else if (type == CCBPropertyType.Color3) { byte r = ReadByte(); byte g = ReadByte(); byte b = ReadByte(); var c = new CCColor3B(r, g, b); value = new CCColor3BWapper(c); } else if (type == CCBPropertyType.Degrees) { value = new CCBValue(ReadFloat()); } else if (type == CCBPropertyType.ScaleLock || type == CCBPropertyType.Position || type == CCBPropertyType.FloatXY) { float a = ReadFloat(); float b = ReadFloat(); value = new List <CCBValue> { new CCBValue(a), new CCBValue(b) }; } else if (type == CCBPropertyType.SpriteFrame) { string spriteSheet = ReadCachedString(); string spriteFile = ReadCachedString(); CCSpriteFrame spriteFrame; if (String.IsNullOrEmpty(spriteSheet)) { spriteFile = _CCBRootPath + spriteFile; CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(CCFileUtils.RemoveExtension(spriteFile)); var bounds = new CCRect(0, 0, texture.ContentSizeInPixels.Width, texture.ContentSizeInPixels.Height); spriteFrame = new CCSpriteFrame(texture, bounds); } else { spriteSheet = _CCBRootPath + spriteSheet; CCSpriteFrameCache frameCache = CCSpriteFrameCache.SharedSpriteFrameCache; // Load the sprite sheet only if it is not loaded if (!_loadedSpriteSheets.Contains(spriteSheet)) { frameCache.AddSpriteFrames(spriteSheet); _loadedSpriteSheets.Add(spriteSheet); } spriteFrame = frameCache[spriteFile]; } value = spriteFrame; } keyframe.Value = value; return(keyframe); }
public CCTransitionFade(float duration, CCScene scene, CCColor3B color) : base(duration, scene) { fadeColor = new CCColor4B { R = color.R, G = color.G, B = color.B, A = 0 }; }
public CCColor4F(CCColor3B color3B) : this(color3B.R / 255.0f, color3B.G / 255.0f, color3B.B / 255.0f, 1.0f) { }
public bool Equals(CCColor3B other) { return(this == other); }
public override void NeedsLayout() { if (!parentInited) { return; } // Hide the background and the label if (titleLabel != null) { titleLabel.Visible = false; } if (_backgroundSprite != null) { _backgroundSprite.Visible = false; } // Update anchor of all labels LabelAnchorPoint = labelAnchorPoint; // Update the label to match with the current state currentTitle = GetTitleForState(State); currentTitleColor = GetTitleColorForState(State); TitleLabel = GetTitleLabelForState(State); var label = (ICCTextContainer)titleLabel; if (label != null && !String.IsNullOrEmpty(currentTitle)) { label.Text = (currentTitle); } var rgbaLabel = titleLabel; if (rgbaLabel != null) { rgbaLabel.Color = currentTitleColor; } if (titleLabel != null) { titleLabel.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2); } // Update the background sprite BackgroundSprite = GetBackgroundSpriteForState(State); if (_backgroundSprite != null) { _backgroundSprite.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2); } // Get the title label size CCSize titleLabelSize = CCSize.Zero; if (titleLabel != null) { titleLabelSize = titleLabel.BoundingBox.Size; } // Adjust the background image if necessary if (isAdjustBackgroundImage) { // Add the margins if (_backgroundSprite != null) { _backgroundSprite.ContentSize = new CCSize(titleLabelSize.Width + _marginH * 2, titleLabelSize.Height + _marginV * 2); } } else { //TODO: should this also have margins if one of the preferred sizes is relaxed? if (_backgroundSprite != null && _backgroundSprite is CCScale9Sprite) { CCSize preferredSize = ((CCScale9Sprite)_backgroundSprite).PreferredSize; if (preferredSize.Width <= 0) { preferredSize.Width = titleLabelSize.Width; } if (preferredSize.Height <= 0) { preferredSize.Height = titleLabelSize.Height; } _backgroundSprite.ContentSize = preferredSize; } } // Set the content size CCRect rectTitle = CCRect.Zero; if (titleLabel != null) { rectTitle = titleLabel.BoundingBox; } CCRect rectBackground = CCRect.Zero; if (_backgroundSprite != null) { rectBackground = _backgroundSprite.BoundingBox; } CCRect maxRect = CCControlUtils.CCRectUnion(rectTitle, rectBackground); ContentSize = new CCSize(maxRect.Size.Width, maxRect.Size.Height); if (titleLabel != null) { titleLabel.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2); // Make visible label titleLabel.Visible = true; } if (_backgroundSprite != null) { _backgroundSprite.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2); // Make visible the background _backgroundSprite.Visible = true; } }
private CCFiniteTimeAction GetAction(CCBKeyframe pKeyframe0, CCBKeyframe pKeyframe1, string pPropName, CCNode node) { float duration = pKeyframe1.Time - (pKeyframe0 != null ? pKeyframe0.Time : 0); switch (pPropName) { case "rotationX": { CCBValue value = (CCBValue)pKeyframe1.Value; return(new CCBRotateXTo(duration, value.GetFloatValue())); } case "rotationY": { CCBValue value = (CCBValue)pKeyframe1.Value; return(new CCBRotateYTo(duration, value.GetFloatValue())); } case "rotation": { var value = (CCBValue)pKeyframe1.Value; return(new CCBRotateTo(duration, value.GetFloatValue())); } case "opacity": { var value = (CCBValue)pKeyframe1.Value; return(new CCFadeTo(duration, value.GetByteValue())); } case "color": { var color = (CCColor3BWapper)pKeyframe1.Value; CCColor3B c = color.Color; return(new CCTintTo(duration, c.R, c.G, c.B)); } case "visible": { var value = (CCBValue)pKeyframe1.Value; if (value.GetBoolValue()) { return(new CCSequence(new CCDelayTime(duration), new CCShow())); } return(new CCSequence(new CCDelayTime(duration), new CCHide())); } case "displayFrame": return(new CCSequence(new CCDelayTime(duration), new CCBSetSpriteFrame((CCSpriteFrame)pKeyframe1.Value))); case "position": { // Get position type var array = (List <CCBValue>)GetBaseValue(node, pPropName); var type = (CCBPositionType)array[2].GetIntValue(); // Get relative position var value = (List <CCBValue>)pKeyframe1.Value; float x = value[0].GetFloatValue(); float y = value[1].GetFloatValue(); CCSize containerSize = GetContainerSize(node.Parent); CCPoint absPos = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, containerSize, pPropName); return(new CCMoveTo(duration, absPos)); } case "scale": { // Get position type var array = (List <CCBValue>)GetBaseValue(node, pPropName); var type = (CCBScaleType)array[2].GetIntValue(); // Get relative scale var value = (List <CCBValue>)pKeyframe1.Value; float x = value[0].GetFloatValue(); float y = value[1].GetFloatValue(); if (type == CCBScaleType.MultiplyResolution) { float resolutionScale = CCBReader.ResolutionScale; x *= resolutionScale; y *= resolutionScale; } return(new CCScaleTo(duration, x, y)); } case "skew": { // Get relative skew var value = (List <CCBValue>)pKeyframe1.Value; float x = value[0].GetFloatValue(); float y = value[1].GetFloatValue(); return(new CCSkewTo(duration, x, y)); } default: CCLog.Log("CCBReader: Failed to create animation for property: {0}", pPropName); break; } return(null); }