/// <summary>
        /// 加载图片
        /// </summary>
        private void LoadPicture()
        {
            String picpath = String.Empty;

            if (IsTruePeople)
            {
                picpath = TruePicturePath;
            }
            else
            {
                picpath = FailPicturePath;
            }
            Picture = Media.PictureManager.GetCCTexture2DWithFile(picpath);
            List <CCSpriteFrame> frames = new List <CCSpriteFrame>();

            for (int i = 0; i < FrameNumber; i++)
            {
                CCSpriteFrame frame = CCSpriteFrame.frameWithTexture(Picture, new CCRect(i * PicWidth, 0, PicWidth, PicHeight));
                frames.Add(frame);
            }
            CCAnimation ani = CCAnimation.animationWithFrames(frames);

            this.initWithSpriteFrame(frames[0]);
            CCAnimate anima = CCAnimate.actionWithDuration(1f, ani, true);

            action = CCRepeat.actionWithAction(anima.reverse(), 3);
        }
Example #2
0
        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 SpriteAnimationSplit()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCTexture2D texture = CCTextureCache.sharedTextureCache().addImage("animations/images/dragon_animation");

            // manually add frames to the frame cache
            CCSpriteFrame frame0 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 0, 132 * 0, 132, 132));
            CCSpriteFrame frame1 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 1, 132 * 0, 132, 132));
            CCSpriteFrame frame2 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 2, 132 * 0, 132, 132));
            CCSpriteFrame frame3 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 3, 132 * 0, 132, 132));
            CCSpriteFrame frame4 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 0, 132 * 1, 132, 132));
            CCSpriteFrame frame5 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 1, 132 * 1, 132, 132));

            //
            // Animation using Sprite BatchNode
            //
            CCSprite sprite = CCSprite.spriteWithSpriteFrame(frame0);

            sprite.position = (new CCPoint(s.width / 2 - 80, s.height / 2));
            addChild(sprite);

            List <CCSpriteFrame> 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.animationWithFrames(animFrames, 0.2f);
            CCAnimate        animate   = CCAnimate.actionWithAnimation(animation, false);
            CCActionInterval seq       = (CCActionInterval)(CCSequence.actions(animate,
                                                                               CCFlipX.actionWithFlipX(true),
                                                                               (CCFiniteTimeAction)animate.copy(),
                                                                               CCFlipX.actionWithFlipX(false)
                                                                               ));

            sprite.runAction(CCRepeatForever.actionWithAction(seq));
            //animFrames->release();    // win32 : memory leak    2010-0415
        }