Beispiel #1
0
        public Sprite6()
        {
            // small capacity. Testing resizing
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);
            AddChild(batch, 0, kTagSpriteBatchNode);
            batch.IgnoreAnchorPointForPosition = true;

            CCSize s = CCDirector.SharedDirector.WinSize;

            batch.AnchorPoint = new CCPoint(0.5f, 0.5f);
            batch.ContentSize = (new CCSize(s.Width, s.Height));


            // SpriteBatchNode actions
            CCActionInterval rotate = new CCRotateBy (5, 360);
            CCAction action = new CCRepeatForever (rotate);

            // SpriteBatchNode actions
            CCActionInterval rotate_back = (CCActionInterval)rotate.Reverse();
            CCActionInterval rotate_seq = (CCActionInterval)(CCSequence.FromActions(rotate, rotate_back));
            CCAction rotate_forever = new CCRepeatForever (rotate_seq);

            CCActionInterval scale = new CCScaleBy(5, 1.5f);
            CCActionInterval scale_back = (CCActionInterval)scale.Reverse();
            CCActionInterval scale_seq = (CCActionInterval)(CCSequence.FromActions(scale, scale_back));
            CCAction scale_forever = new CCRepeatForever (scale_seq);

            float step = s.Width / 4;

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121));
                sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));

                sprite.RunAction((CCAction)(action.Copy()));
                batch.AddChild(sprite, i);
            }

            batch.RunAction(scale_forever);
            batch.RunAction(rotate_forever);
        }
        public SpriteBatchNodeZVertex()
        {
            //
            // This test tests z-order
            // If you are going to use it is better to use a 3D projection
            //
            // WARNING:
            // The developer is resposible for ordering it's sprites according to it's Z if the sprite has
            // transparent parts.
            //


            CCSize s = CCDirector.SharedDirector.WinSize;
            float step = s.Width / 12;

            // small capacity. Testing resizing.
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);
            // camera uses the center of the image as the pivoting point
            batch.ContentSize = new CCSize(s.Width, s.Height);
            batch.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            batch.Position = (new CCPoint(s.Width / 2, s.Height / 2));


            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            for (int i = 0; i < 5; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
                sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));
                sprite.VertexZ = (10 + i * 40);
                batch.AddChild(sprite, 0);

            }

            for (int i = 5; i < 11; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 0, 85, 121));
                sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));
                sprite.VertexZ = 10 + (10 - i) * 40;
                batch.AddChild(sprite, 0);
            }

            batch.RunAction(new CCOrbitCamera(10, 1, 0, 0, 360, 0, 0));
        }