Пример #1
0
 public CCFlipYState(CCFlipY action, CCNode target)
     : base(action, target)
 {
     if (!(target is CCSprite))
     {
         throw (new System.NotSupportedException("FlipX and FlipY actions only work on CCSprite instances."));
     }
     ((CCSprite)(target)).FlipY = action.FlipY;
 }
Пример #2
0
        public CCFlipYState (CCFlipY action, CCNode target)
            : base (action, target)
        {   

            if (!(target is CCSprite))
            {
                throw (new System.NotSupportedException ("FlipX and FlipY actions only work on CCSprite instances."));
            }
            ((CCSprite)(target)).FlipY = action.FlipY;      
        }
Пример #3
0
        public static CCFlipY actionWithFlipY(bool y)
        {
            CCFlipY pRet = new CCFlipY();

            if (pRet != null && pRet.initWithFlipY(y))
            {
                return(pRet);
            }

            return(null);
        }
Пример #4
0
        public static CCFlipY actionWithFlipY(bool y)
        {
            CCFlipY pRet = new CCFlipY();

            if (pRet != null && pRet.initWithFlipY(y))
            {
                return pRet;
            }

            return null;
        }
Пример #5
0
        public SpriteBatchNodeOffsetAnchorFlip()
        {
            CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;

            cache.AddSpriteFrames("animations/grossini.plist");
            cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray");

            // Create animations and actions

            var    animFrames = new List <CCSpriteFrame>();
            string tmp        = "";

            for (int j = 0; j < 14; j++)
            {
                string temp = "";
                if (j + 1 < 10)
                {
                    temp = "0" + (j + 1);
                }
                else
                {
                    temp = (j + 1).ToString();
                }

                tmp = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame = cache[tmp];
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.3f);


            CCFlipY     flip      = new CCFlipY(true);
            CCFlipY     flip_back = new CCFlipY(false);
            CCDelayTime delay     = new CCDelayTime(1);

            seq = new CCSequence(delay, flip, delay, flip_back);

            sprites      = new CCSprite[numOfSprites];
            pointSprites = new CCSprite[numOfSprites];

            for (int i = 0; i < numOfSprites; i++)
            {
                // Animation using Sprite batch
                sprites[i]      = new CCSprite("grossini_dance_01.png");
                pointSprites[i] = new CCSprite("Images/r1");

                CCSpriteBatchNode spritebatch = new CCSpriteBatchNode("animations/grossini");
                AddChild(spritebatch);
                AddChild(pointSprites[i], 200);
                spritebatch.AddChild(sprites[i], i);
            }
        }
Пример #6
0
        public override object Copy(ICopyable pZone)
        {
            CCFlipY pRet;

            if (pZone != null)
            {
                pRet = (CCFlipY) (pZone);
            }
            else
            {
                pRet = new CCFlipY();
                pZone =  (pRet);
            }

            base.Copy(pZone);
            pRet.InitWithFlipY(m_bFlipY);
            return pRet;
        }
Пример #7
0
        public override object Copy(ICopyable pZone)
        {
            CCFlipY pRet;

            if (pZone != null)
            {
                pRet = (CCFlipY)(pZone);
            }
            else
            {
                pRet  = new CCFlipY();
                pZone = (pRet);
            }

            base.Copy(pZone);
            pRet.InitWithFlipY(m_bFlipY);
            return(pRet);
        }
Пример #8
0
        public override CCObject copyWithZone(CCZone pZone)
        {
            CCZone  pNewZone = null;
            CCFlipY pRet     = null;

            if (pZone != null && pZone.m_pCopyObject != null)
            {
                pRet = (CCFlipY)(pZone.m_pCopyObject);
            }
            else
            {
                pRet  = new CCFlipY();
                pZone = pNewZone = new CCZone(pRet);
            }

            base.copyWithZone(pZone);
            pRet.initWithFlipY(m_bFlipY);
            return(pRet);
        }
Пример #9
0
        public override CCObject copyWithZone(CCZone pZone)
        {
            CCZone pNewZone = null;
            CCFlipY pRet = null;

            if (pZone != null && pZone.m_pCopyObject != null)
            {
                pRet = (CCFlipY)(pZone.m_pCopyObject);
            }
            else
            {
                pRet = new CCFlipY();
                pZone = pNewZone = new CCZone(pRet);
            }

            base.copyWithZone(pZone);
            pRet.initWithFlipY(m_bFlipY);
            return pRet;
        }
        public SpriteBatchNodeOffsetAnchorFlip()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            for (int i = 0; i < 3; i++)
            {
                CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;
                cache.AddSpriteFramesWithFile("animations/grossini.plist");
                cache.AddSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray");

                //
                // Animation using Sprite batch
                //
                CCSprite sprite = new CCSprite("grossini_dance_01.png");
                sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2));

                CCSprite point = new CCSprite("Images/r1");
                point.Scale    = 0.25f;
                point.Position = sprite.Position;
                AddChild(point, 200);

                switch (i)
                {
                case 0:
                    sprite.AnchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.AnchorPoint = new CCPoint(0.5f, 0.5f);
                    break;

                case 2:
                    sprite.AnchorPoint = (new CCPoint(1, 1));
                    break;
                }

                point.Position = sprite.Position;

                CCSpriteBatchNode spritebatch = new CCSpriteBatchNode("animations/grossini");
                AddChild(spritebatch);

                var    animFrames = new List <CCSpriteFrame>();
                string tmp        = "";
                for (int j = 0; j < 14; j++)
                {
                    string temp = "";
                    if (i + 1 < 10)
                    {
                        temp = "0" + (i + 1);
                    }
                    else
                    {
                        temp = (i + 1).ToString();
                    }
                    tmp = string.Format("grossini_dance_{0}.png", temp);
                    CCSpriteFrame frame = cache.SpriteFrameByName(tmp);
                    animFrames.Add(frame);
                }

                CCAnimation animation = new CCAnimation(animFrames, 0.3f);
                sprite.RunAction(new CCRepeatForever(new CCAnimate(animation)));

                animFrames = null;

                CCFlipY            flip      = new CCFlipY(true);
                CCFlipY            flip_back = new CCFlipY(false);
                CCDelayTime        delay     = new CCDelayTime(1);
                CCFiniteTimeAction seq       = CCSequence.FromActions((CCFiniteTimeAction)delay, (CCFiniteTimeAction)flip, (CCFiniteTimeAction)delay.Copy(null), (CCFiniteTimeAction)flip_back);
                sprite.RunAction(new CCRepeatForever((CCActionInterval)seq));

                spritebatch.AddChild(sprite, i);
            }
        }
Пример #11
0
 protected CCFlipY(CCFlipY flipY) : base(flipY)
 {
     InitWithFlipY(m_bFlipY);
 }
Пример #12
0
 public static CCFlipY Create(bool y)
 {
     var pRet = new CCFlipY();
     pRet.InitWithFlipY(y);
     return pRet;
 }
Пример #13
0
 protected CCFlipY(CCFlipY flipY) : base(flipY)
 {
     InitWithFlipY(m_bFlipY);
 }
        public SpriteBatchNodeOffsetAnchorFlip()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            for (int i = 0; i < 3; i++)
            {
                CCSpriteFrameCache cache = CCSpriteFrameCache.sharedSpriteFrameCache();
                cache.addSpriteFramesWithFile("animations/grossini");
                cache.addSpriteFramesWithFile("animations/grossini_gray", "animations/images/grossini_gray");

                //
                // Animation using Sprite batch
                //
                CCSprite sprite = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");
                sprite.position = (new CCPoint(s.width / 4 * (i + 1), s.height / 2));

                CCSprite point = CCSprite.spriteWithFile("Images/r1");
                point.scale    = 0.25f;
                point.position = sprite.position;
                addChild(point, 200);

                switch (i)
                {
                case 0:
                    sprite.anchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.anchorPoint = new CCPoint(0.5f, 0.5f);
                    break;

                case 2:
                    sprite.anchorPoint = (new CCPoint(1, 1));
                    break;
                }

                point.position = sprite.position;

                CCSpriteBatchNode spritebatch = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini");
                addChild(spritebatch);

                List <CCSpriteFrame> animFrames = new List <CCSpriteFrame>();
                string tmp = "";
                for (int j = 0; j < 14; j++)
                {
                    string temp = "";
                    if (i + 1 < 10)
                    {
                        temp = "0" + (i + 1);
                    }
                    else
                    {
                        temp = (i + 1).ToString();
                    }
                    tmp = string.Format("grossini_dance_{0}.png", temp);
                    CCSpriteFrame frame = cache.spriteFrameByName(tmp);
                    animFrames.Add(frame);
                }

                CCAnimation animation = CCAnimation.animationWithFrames(animFrames);
                sprite.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithDuration(2.8f, animation, false)));

                animFrames = null;

                CCFlipY            flip      = CCFlipY.actionWithFlipY(true);
                CCFlipY            flip_back = CCFlipY.actionWithFlipY(false);
                CCDelayTime        delay     = CCDelayTime.actionWithDuration(1);
                CCFiniteTimeAction seq       = CCSequence.actions((CCFiniteTimeAction)delay, (CCFiniteTimeAction)flip, (CCFiniteTimeAction)delay.copyWithZone(null), (CCFiniteTimeAction)flip_back);
                sprite.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));

                spritebatch.addChild(sprite, i);
            }
        }