public void InitializeBear() { var spriteSheet = new CCSpriteSheet("animations/AnimBear.plist"); var walkAnimation = new CCAnimation(spriteSheet.Frames, 0.1f); bearAction = new CCRepeatForever(new CCAnimate(walkAnimation)); bearSprite = new CCSprite(spriteSheet.Frames.First()) { Name = "Bear" }; }
public CCSpriteSheet AddSpriteSheet(string fileName, CCTexture2D texture) { CCSpriteSheet result; if (!spriteSheets.TryGetValue(fileName, out result)) { result = new CCSpriteSheet(fileName, texture); spriteSheets.Add(fileName, result); } return result; }
public CCAnimation(CCSpriteSheet cs, string[] frames, float delay) { List<CCSpriteFrame> l = new List<CCSpriteFrame>(); foreach(string f in frames) { CCSpriteFrame cf = cs[f]; if (cf != null) l.Add(cs[f]); } InitWithSpriteFrames(l, delay); }
public void AddMonkey () { var spriteSheet = new CCSpriteSheet ("animations/monkey.plist"); var frame = spriteSheet.Frames.Find ((x) => x.TextureFilename.StartsWith ("frame")); var monkey = new CCSprite (frame) { Position = new CCPoint (VisibleBoundsWorldspace.Size.Center.X + 20, VisibleBoundsWorldspace.Size.Center.Y + 300 * sy), Scale = 0.5f * (sx > sy ? sx : sy), }; AddChild (monkey); }
public Player() { CCSpriteSheet tmp = new CCSpriteSheet("poring.plist"); //List<CCSpriteFrame> elementos = new List<CCSpriteFrame>(); //for (int i = 1; i <= 3; i++) //{ // tmp = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(String.Format("walk{0}.png", i)); // elementos.Add(tmp); //} CCAnimation anim = new CCAnimation(tmp.Frames, 0.5f); CCRepeatForever rep = new CCRepeatForever(new CCAnimate(anim)); RunAction(rep); }
public override void OnEnter() { base.OnEnter(); if (Parent.Tag == Tags.Client) { var ss = new CCSpriteSheet("MysticAnim.plist"); var walkAnim = new CCAnimation(ss.Frames, 0.3f); foreach (CCSpriteFrame sf in ss.Frames) { sf.Texture.IsAntialiased = false; } AddAction(new CCRepeatForever(new CCAnimate(walkAnim))); } Schedule(Update); }
public void Remove(CCSpriteSheet spriteSheet) { if (spriteSheet == null) { return; } string key = null; foreach (var pair in spriteSheets) { if (pair.Value == spriteSheet) { key = pair.Key; break; } } if (key != null) { spriteSheets.Remove(key); } }
void CreateLayout() { CCSpriteSheet sheet = new CCSpriteSheet ("sheet.plist", "sheet.png"); CCSpriteFrame frame; // create the far background for (int i = 0; i < 3; i++) { frame = sheet.Frames.Find(item=>item.TextureFilename == "farBackground.png"); CCSprite sprite = new CCSprite (frame); sprite.AnchorPoint = new CCPoint (0, 0); sprite.Scale = 3; sprite.PositionX = i * sprite.ScaledContentSize.Width; // offset it a bit upward to fill the empty space sprite.PositionY = 100; this.AddChild (sprite); } // create the forest background for (int i = 0; i < 3; i++) { frame = sheet.Frames.Find(item=>item.TextureFilename == "forestBackground.png"); CCSprite sprite = new CCSprite (frame); sprite.AnchorPoint = new CCPoint (0, 0); sprite.Scale = 3; sprite.PositionX = i * sprite.ScaledContentSize.Width; this.AddChild (sprite); } // create the foreground: frame = sheet.Frames.Find(item=>item.TextureFilename == "foreground.png"); CCSprite foreground = new CCSprite (frame); foreground.Scale = 3; foreground.AnchorPoint = new CCPoint (0, 0); this.AddChild (foreground); }
/// <summary> /// Initializes a new instance of the <see cref="Client.Common.Views.UnitDefinitionView"/> class. /// </summary> /// <param name="model">The model.</param> public UnitDefinitionView(Core.Models.Definitions.UnitDefinition model) : base(model) { m_animations = new Dictionary<Core.Models.Diplomatic, Dictionary<UnitAnimation, CCAnimate>>(); m_spritesheets = new Dictionary<Core.Models.Diplomatic, CCSpriteSheet>(); var filename = model.ID.ToString(); foreach (Core.Models.Diplomatic situation in Enum.GetValues(typeof(Core.Models.Diplomatic))) { m_animations[situation] = new Dictionary<UnitAnimation, CCAnimate>(); var plist = "unit_" + filename + "-" + situation.ToString() + ".plist"; var png = "unit_" + filename + "-" + situation.ToString() + ".png"; try { m_spritesheets[situation] = new CCSpriteSheet(plist, png); var defaultSprite = m_spritesheets[situation].Frames.Find((x) => x.TextureFilename.Contains("default")); var idle = m_spritesheets[situation].Frames.FindAll((x) => x.TextureFilename.Contains("idle")); var fight = m_spritesheets[situation].Frames.FindAll((x) => x.TextureFilename.Contains("attack")); var walk = m_spritesheets[situation].Frames.FindAll((x) => x.TextureFilename.Contains("run")); var die = m_spritesheets[situation].Frames.FindAll((x) => x.TextureFilename.Contains("die")); idle.Add(defaultSprite); fight.Add(defaultSprite); walk.Add(defaultSprite); m_animations[situation][UnitAnimation.Idle] = new CCAnimate(new CCAnimation(idle, 0.25f)); m_animations[situation][UnitAnimation.Fight] = new CCAnimate(new CCAnimation(fight, 0.25f)); m_animations[situation][UnitAnimation.Die] = new CCAnimate(new CCAnimation(die, 0.25f)); } catch (Exception err) { Logging.Error(err.Message); Logging.Error("View.UnitDefinitionView: Couldn't load UnitDefinitionView. " + plist + " or " + png + " are incorrect."); } } }
public void Remove(CCSpriteSheet spriteSheet) { if (spriteSheet == null) { return; } string key = null; foreach (var pair in spriteSheets) { if (pair.Value == spriteSheet) { key = pair.Key; break; } } if (key != null) { spriteSheets.Remove(key); } }
void AddMonkey() { var spriteSheet = new CCSpriteSheet ("animations/monkey.plist"); var animationFrames = spriteSheet.Frames.FindAll ((x) => x.TextureFilename.StartsWith ("frame")); walkAnim = new CCAnimation (animationFrames, 0.1f); walkRepeat = new CCRepeatForever (new CCAnimate (walkAnim)); monkey = new CCSprite (animationFrames.First ()) { Name = "Monkey" }; monkey.Scale = 0.25f; AddChild (monkey); }
CCSprite AddBanana() { var spriteSheet = new CCSpriteSheet ("animations/monkey.plist"); var banana = new CCSprite (spriteSheet.Frames.Find ((x) => x.TextureFilename.StartsWith ("Banana"))); var p = GetRandomPosition (banana.ContentSize); banana.Position = p; banana.Scale = 0.5f; AddChild (banana); var moveBanana = new CCMoveTo (5.0f, new CCPoint (banana.Position.X, 0)); banana.RunActions (moveBanana, moveBananaComplete); banana.RepeatForever (rotateBanana); return banana; }
public CCAnimation(CCSpriteSheet cs, float delay) : this(cs.Frames, delay) { }
void AddMonkey() { var spriteSheet = new CCSpriteSheet ("animations/monkey.plist"); var animationFrames = spriteSheet.Frames.FindAll ((x) => x.TextureFilename.StartsWith ("frame")); walkAnim = new CCAnimation (animationFrames, 0.1f); walkRepeat = new CCRepeatForever (new CCAnimate (walkAnim)); monkey = new CCSprite (animationFrames.First ()) { Name = "Monkey" }; var baselineScale = 0.25f; //monkey image actual size is 4x what looks good at baseline, so scale by 0.25 for baseline var contentScale = contentScaleFactorX > contentScaleFactorY ? contentScaleFactorX : contentScaleFactorY; //use the larger scale if they are not equal monkey.Scale = baselineScale * contentScale; AddChild (monkey); }
public void InitializeMonkey() { var spriteSheet = new CCSpriteSheet("animations/monkey.plist"); var walkAnimation = new CCAnimation(spriteSheet.Frames, 0.1f); monkeyAction = new CCRepeatForever(new CCAnimate(walkAnimation)); // Load the frames using the Frames property which var animationFrames = spriteSheet.Frames.FindAll((x) => { return x.TextureFilename.StartsWith("frame"); }); monkeySprite = new CCSprite(animationFrames.First()) { Name = "Monkey" }; monkeySprite.Scale = 0.5f; }
public CCAnimation(CCSpriteSheet cs, float delay) : this(cs.Frames, delay) { }