public static CCAnimate actionWithAnimation(CCAnimation pAnimation) { CCAnimate pAnimate = new CCAnimate(); pAnimate.initWithAnimation(pAnimation, true); return pAnimate; }
public static CCAnimate actionWithAnimation(CCAnimation pAnimation, bool bRestoreOriginalFrame) { CCAnimate pAnimate = new CCAnimate(); pAnimate.initWithAnimation(pAnimation, bRestoreOriginalFrame); return pAnimate; }
public static CCAnimate actionWithDuration(float duration, CCAnimation pAnimation, bool bRestoreOriginalFrame) { CCAnimate pAnimate = new CCAnimate(); pAnimate.initWithDuration(duration, pAnimation, bRestoreOriginalFrame); return pAnimate; }
public static CCAnimate actionWithDuration(float duration, CCAnimation pAnimation, bool bRestoreOriginalFrame) { CCAnimate animate = new CCAnimate(); animate.initWithDuration(duration, pAnimation, bRestoreOriginalFrame); return(animate); }
public static CCAnimate actionWithAnimation(CCAnimation pAnimation, bool bRestoreOriginalFrame) { CCAnimate animate = new CCAnimate(); animate.initWithAnimation(pAnimation, bRestoreOriginalFrame); return(animate); }
public static CCAnimate actionWithAnimation(CCAnimation pAnimation) { CCAnimate animate = new CCAnimate(); animate.initWithAnimation(pAnimation, true); return(animate); }
public override void OnEnter() { base.OnEnter(); centerSprites(3); // // Manual animation // var animation = CCAnimation.Create(); for (var i = 1; i < 15; i++) { var szName = String.Format("Images/grossini_dance_{0:00}", i); animation.AddSpriteFrameWithFileName(szName); } // should last 2.8 seconds. And there are 14 frames. animation.DelayPerUnit = 2.8f / 14.0f; animation.RestoreOriginalFrame = true; var action = new CCAnimate (animation); m_grossini.RunAction(CCSequence.FromActions(action, action.Reverse())); // // File animation // // With 2 loops and reverse var cache = CCAnimationCache.SharedAnimationCache; cache.AddAnimationsWithFile("animations/animations-2.plist"); var animation2 = cache.AnimationByName("dance_1"); var action2 = new CCAnimate (animation2); m_tamara.RunAction(CCSequence.FromActions(action2, action2.Reverse())); // TODO: // observer_ = [[NSNotificationCenter defaultCenter] addObserverForName:CCAnimationFrameDisplayedNotification object:nil queue:nil usingBlock:^(NSNotification* notification) { // // NSDictionary *userInfo = [notification userInfo]; // NSLog(@"object %@ with data %@", [notification object], userInfo ); // }]; // // File animation // // with 4 loops var animation3 = (CCAnimation) animation2.Copy(); animation3.Loops = 4; var action3 = new CCAnimate (animation3); m_kathia.RunAction(action3); }
private void LoadPicture() { CCTexture2D speakerpic = Media.PictureManager.GetCCTexture2DWithFile(PictuerName); List<CCSpriteFrame> frames = new List<CCSpriteFrame>(); for (int i = 0; i < FrameNumber; i++) { CCSpriteFrame frame = CCSpriteFrame.frameWithTexture(speakerpic, new CCRect(i * PictuerWidth, 0, PictuerWidth, PictuerHeight)); frames.Add(frame); } CCAnimation ani = CCAnimation.animationWithFrames(frames); this.initWithSpriteFrame(frames[0]); action = CCAnimate.actionWithDuration(1f, ani, true); }
public CCAnimate CreateAnimateAction() { var frameList = new List<CCSpriteFrame>(); for (var i = 0; i < 7; i++) { var texture = CreateCharacterTexture(); var sprite = CCSpriteFrame.Create(texture, new CCRect(0, 0, texture.ContentSize.Width, texture.ContentSize.Height)); frameList.Add(sprite); } var animation = CCAnimation.Create(frameList, 0.1f); var animate = new CCAnimate (animation); return animate; }
public override CCObject copyWithZone(CCZone pZone) { CCAnimate pCopyObject = null; if ((pZone != null) && (pZone.m_pCopyObject != null)) { pCopyObject = (CCAnimate)pZone.m_pCopyObject; } else { pCopyObject = new CCAnimate(); pZone = new CCZone(pCopyObject); } base.copyWithZone(pZone); pCopyObject.initWithDuration(base.m_fDuration, this.m_pAnimation, this.m_bRestoreOriginalFrame); return(pCopyObject); }
public override CCObject copyWithZone(CCZone pZone) { CCZone pNewZone = null; CCAnimate pCopy = null; if(pZone !=null && pZone.m_pCopyObject != null) { //in case of being called at sub class pCopy = (CCAnimate)(pZone.m_pCopyObject); } else { pCopy = new CCAnimate(); pZone = pNewZone = new CCZone(pCopy); } base.copyWithZone(pZone); pCopy.initWithDuration(Duration, m_pAnimation, m_bRestoreOriginalFrame); return pCopy; }
public SpriteAnimationSplit() { CCSize s = CCDirector.SharedDirector.WinSize; CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage("animations/dragon_animation"); // manually add frames to the frame cache CCSpriteFrame frame0 = CCSpriteFrame.Create(texture, new CCRect(132 * 0, 132 * 0, 132, 132)); CCSpriteFrame frame1 = CCSpriteFrame.Create(texture, new CCRect(132 * 1, 132 * 0, 132, 132)); CCSpriteFrame frame2 = CCSpriteFrame.Create(texture, new CCRect(132 * 2, 132 * 0, 132, 132)); CCSpriteFrame frame3 = CCSpriteFrame.Create(texture, new CCRect(132 * 3, 132 * 0, 132, 132)); CCSpriteFrame frame4 = CCSpriteFrame.Create(texture, new CCRect(132 * 0, 132 * 1, 132, 132)); CCSpriteFrame frame5 = CCSpriteFrame.Create(texture, new CCRect(132 * 1, 132 * 1, 132, 132)); // // Animation using Sprite BatchNode // CCSprite sprite = new CCSprite(frame0); sprite.Position = (new CCPoint(s.Width / 2 - 80, s.Height / 2)); AddChild(sprite); var animFrames = new List<CCSpriteFrame>(6); animFrames.Add(frame0); animFrames.Add(frame1); animFrames.Add(frame2); animFrames.Add(frame3); animFrames.Add(frame4); animFrames.Add(frame5); CCAnimation animation = CCAnimation.Create(animFrames, 0.2f); CCAnimate animate = new CCAnimate (animation); CCActionInterval seq = (CCActionInterval)(CCSequence.FromActions(animate, CCFlipX.Create(true), (CCFiniteTimeAction)animate.Copy(), CCFlipX.Create(false) )); sprite.RunAction(new CCRepeatForever (seq)); //animFrames->release(); // win32 : memory leak 2010-0415 }
public override CCObject copyWithZone(CCZone pZone) { CCZone pNewZone = null; CCAnimate pCopy = null; if (pZone != null && pZone.m_pCopyObject != null) { //in case of being called at sub class pCopy = (CCAnimate)(pZone.m_pCopyObject); } else { pCopy = new CCAnimate(); pZone = pNewZone = new CCZone(pCopy); } base.copyWithZone(pZone); pCopy.initWithDuration(m_fDuration, m_pAnimation, m_bRestoreOriginalFrame); return(pCopy); }
public Uncle_sprite() { //uncledata = data; // 创建走的动画 List<CCSpriteFrame> _runFream = new List<CCSpriteFrame>(); CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile(@"plist/zhengyu"); CCSpriteBatchNode sheet = CCSpriteBatchNode.batchNodeWithFile(@"plist/Images/zhengyu"); this.addChild(sheet); for (int i = 1; i <= 4; i++) { _runFream.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(String.Format("MM0{0}.png", i))); } _run = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_runFream, 0.12f)); List<CCSpriteFrame> _actackFream = new List<CCSpriteFrame>(); // 创建攻击时候动作 for (int i = 1; i <= 5; i++) { _actackFream.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(String.Format("Mthrow0{0}.png", i))); } _actack = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_actackFream, 0.3f)); position = new CCPoint(100, 100); // 初始化开始帧 base.initWithSpriteFrame(_runFream[0]); // 如果手机倾斜 if (Accelerometer.IsSupported) { gSensor = new Accelerometer(); gSensor.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<AccelerometerReading>>(gSensor_CurrentValueChanged); gSensor.Start(); } }
public override CCFiniteTimeAction reverse() { List <CCSpriteFrame> pOldArray = m_pAnimation.getFrames(); List <CCSpriteFrame> pNewArray = new List <CCSpriteFrame>(pOldArray.Count); if (pOldArray.Count > 0) { CCSpriteFrame pElement; for (int nIndex = pOldArray.Count - 1; nIndex >= 0; nIndex--) { pElement = pOldArray[nIndex]; if (null == pElement) { break; } pNewArray.Insert(pOldArray.Count - 1 - nIndex, (CCSpriteFrame)(pElement.copy())); } } CCAnimation pNewAnim = CCAnimation.animationWithFrames(pNewArray, m_pAnimation.getDelay()); return(CCAnimate.actionWithDuration(m_fDuration, pNewAnim, m_bRestoreOriginalFrame)); }
public AnimationCache() { var frameCache = CCSpriteFrameCache.SharedSpriteFrameCache; frameCache.AddSpriteFramesWithFile("animations/grossini.plist"); frameCache.AddSpriteFramesWithFile("animations/grossini_gray.plist"); frameCache.AddSpriteFramesWithFile("animations/grossini_blue.plist"); // // create animation "dance" // var animFrames = new List<CCSpriteFrame>(15); string str = ""; for (int i = 1; i < 15; i++) { str = string.Format("grossini_dance_{0:00}.png", i); CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str); animFrames.Add(frame); } CCAnimation animation = CCAnimation.Create(animFrames, 0.2f); // Add an animation to the Cache CCAnimationCache.SharedAnimationCache.AddAnimation(animation, "dance"); // // create animation "dance gray" // animFrames.Clear(); for (int i = 1; i < 15; i++) { str = String.Format("grossini_dance_gray_{0:00}.png", i); CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str); animFrames.Add(frame); } animation = CCAnimation.Create(animFrames, 0.2f); // Add an animation to the Cache CCAnimationCache.SharedAnimationCache.AddAnimation(animation, "dance_gray"); // // create animation "dance blue" // animFrames.Clear(); for (int i = 1; i < 4; i++) { str = String.Format("grossini_blue_{0:00}.png", i); CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str); animFrames.Add(frame); } animation = CCAnimation.Create(animFrames, 0.2f); // Add an animation to the Cache CCAnimationCache.SharedAnimationCache.AddAnimation(animation, "dance_blue"); CCAnimationCache animCache = CCAnimationCache.SharedAnimationCache; CCAnimation normal = animCache.AnimationByName("dance"); normal.RestoreOriginalFrame = true; CCAnimation dance_grey = animCache.AnimationByName("dance_gray"); dance_grey.RestoreOriginalFrame = true; CCAnimation dance_blue = animCache.AnimationByName("dance_blue"); dance_blue.RestoreOriginalFrame = true; CCAnimate animN = new CCAnimate (normal); CCAnimate animG = new CCAnimate (dance_grey); CCAnimate animB = new CCAnimate (dance_blue); CCFiniteTimeAction seq = CCSequence.FromActions(animN, animG, animB); // create an sprite without texture CCSprite grossini = new CCSprite(); grossini.DisplayFrame = frameCache.SpriteFrameByName("grossini_dance_01.png"); CCSize winSize = CCDirector.SharedDirector.WinSize; grossini.Position = (new CCPoint(winSize.Width / 2, winSize.Height / 2)); AddChild(grossini); // run the animation grossini.RunAction(seq); }
public RenderTextureCompositeTest() { var winSize = CCDirector.SharedDirector.WinSize; var characterSpriteFactory = new CharacterSpriteFactory(); _testSprite = new CCSprite(@"Images\grossini_dance_01"); _testSprite2 = new CCSprite(@"Images\grossini_dance_02"); _swingAnimate = characterSpriteFactory.CreateAnimateAction(); _thrustAnimate = characterSpriteFactory.CreateAnimateAction(); _dodgeAnimate = characterSpriteFactory.CreateAnimateAction(); _collapseAnimate = characterSpriteFactory.CreateAnimateAction(); _swingAnimate2 = characterSpriteFactory.CreateAnimateAction(); _thrustAnimate2 = characterSpriteFactory.CreateAnimateAction(); _dodgeAnimate2 = characterSpriteFactory.CreateAnimateAction(); _collapseAnimate2 = characterSpriteFactory.CreateAnimateAction(); _testSprite.Position = new CCPoint(winSize.Width / 2 -200, winSize.Height / 2 + 100); AddChild(_testSprite); _testSprite2.Position = new CCPoint(winSize.Width / 2 + 200, winSize.Height / 2 + 100); _testSprite2.FlipX = true; AddChild(_testSprite2); AnimationLoop(); AnimationLoop2(); }
protected CCAnimate(CCAnimate animate) : base(animate) { InitWithAnimation((CCAnimation) animate.m_pAnimation.Copy()); }
//播放循环动画的统一方法 private void RunAnimateAction_RepeatForever(CCAnimate action) { currentAnimateActionStop(); _currentAnimateAction = runAction(CCRepeatForever.actionWithAction(action)); }