Exemplo n.º 1
0
        public Color TileAt(CCGridSize position)
        {
            Debug.Assert(m_pTGAInfo != null, "tgaInfo must not be nil");
            Debug.Assert(position.X < m_pTGAInfo.width, "Invalid position.x");
            Debug.Assert(position.Y < m_pTGAInfo.height, "Invalid position.y");

            return m_pTGAInfo.imageData[position.X + position.Y * m_pTGAInfo.width];
        }
Exemplo n.º 2
0
 public override float TestFunc(CCGridSize pos, float time)
 {
     float fy = m_sGridSize.Y * time;
     if(fy == 0f) {
         return(1f);
     }
     return (float) Math.Pow(pos.Y / fy, 6);
 }
Exemplo n.º 3
0
        public override void Update(float time)
        {
            float tt = Math.Max(0, time - 0.25f);
            float deltaAy = (tt * tt * 500);
            float ay = -100 - deltaAy;

            float deltaTheta = -MathHelper.PiOver2 * (float) Math.Sqrt(time);
            float theta = /*0.01f */ +MathHelper.PiOver2 + deltaTheta;

            var sinTheta = (float) Math.Sin(theta);
            var cosTheta = (float) Math.Cos(theta);

            for (int i = 0; i <= m_sGridSize.X; ++i)
            {
                for (int j = 0; j <= m_sGridSize.Y; ++j)
                {
                    // Get original vertex
                    var gs = new CCGridSize(i, j);
                    CCVertex3F p = OriginalVertex(gs);

                    var R = (float) Math.Sqrt((p.X * p.X) + ((p.Y - ay) * (p.Y - ay)));
                    float r = R * sinTheta;
                    var alpha = (float) Math.Asin(p.X / R);
                    float beta = alpha / sinTheta;
                    var cosBeta = (float) Math.Cos(beta);

                    // If beta > PI then we've wrapped around the cone
                    // Reduce the radius to stop these points interfering with others
                    if (beta <= MathHelper.Pi)
                    {
                        p.X = (r * (float) Math.Sin(beta));
                    }
                    else
                    {
                        // Force X = 0 to stop wrapped
                        // points
                        p.X = 0;
                    }

                    p.Y = (R + ay - (r * (1 - cosBeta) * sinTheta));

                    // We scale z here to avoid the animation being
                    // too much bigger than the screen due to perspective transform
                    p.Z = (r * (1 - cosBeta) * cosTheta) / 7; // "100" didn't work for

                    //    Stop z coord from dropping beneath underlying page in a transition
                    // issue #751
                    if (p.Z < 0.5f)
                    {
                        p.Z = 0.5f;
                    }

                    // Set new coords
                    SetVertex(gs, ref p);
                }
            }
        }
Exemplo n.º 4
0
 public virtual bool InitWithSize(CCGridSize gridSize, float duration)
 {
     if (base.InitWithDuration(duration))
     {
         m_sGridSize = gridSize;
         return true;
     }
     return false;
 }
Exemplo n.º 5
0
 public static CCTiledGrid3D Create(CCGridSize gridSize, CCTexture2D pTexture, bool bFlipped)
 {
     var pRet = new CCTiledGrid3D();
     if (pRet.InitWithSize(gridSize, pTexture, bFlipped))
     {
         return pRet;
     }
     return null;
 }
Exemplo n.º 6
0
 public static CCTiledGrid3D Create(CCGridSize gridSize)
 {
     var pRet = new CCTiledGrid3D();
     if (pRet.InitWithSize(gridSize))
     {
         return pRet;
     }
     return null;
 }
Exemplo n.º 7
0
        public override float TestFunc(CCGridSize pos, float time)
        {
            var n = new CCPoint((m_sGridSize.X * (1.0f - time)), (m_sGridSize.Y * (1.0f - time)));
            if ((pos.X + pos.Y) == 0)
            {
                return 1.0f;
            }

            return (float) Math.Pow((n.X + n.Y) / (pos.X + pos.Y), 6);
        }
Exemplo n.º 8
0
        public virtual float TestFunc(CCGridSize pos, float time)
        {
            float px = m_sGridSize.X * time;
            float py = m_sGridSize.Y * time;
            if ((px + py) == 0.0f)
            {
                return 1.0f;
            }

            return (float) Math.Pow((pos.X + pos.Y) / (px + py), 6);
        }
Exemplo n.º 9
0
 public bool InitWithWaves(int wav, float amp, CCGridSize gridSize, float duration)
 {
     if (InitWithSize(gridSize, duration))
     {
         m_nWaves = wav;
         m_fAmplitude = amp;
         m_fAmplitudeRate = 1.0f;
         return true;
     }
     return false;
 }
Exemplo n.º 10
0
        public override bool InitWithSize(CCGridSize gridSize, float duration)
        {
            if (gridSize.X != 1 || gridSize.Y != 1)
            {
                // Grid size must be (1,1)
                Debug.Assert(false);
                return false;
            }

            return base.InitWithSize(gridSize, duration);
        }
Exemplo n.º 11
0
        public override void TransformTile(CCGridSize pos, float distance)
        {
            CCQuad3 coords = OriginalTile(pos);
            CCPoint step = m_pTarget.Grid.Step;

            float dy = (step.Y / 2) * (1.0f - distance);

            coords.BottomLeft.Y += dy; // (step.Y / 2) * (1.0f - distance);
            coords.BottomRight.Y += dy; //  (step.Y / 2) * (1.0f - distance);
            coords.TopLeft.Y -= dy; //  (step.Y / 2) * (1.0f - distance);
            coords.TopRight.Y -= dy; // (step.Y / 2) * (1.0f - distance);

            SetTile(pos, ref coords);
        }
Exemplo n.º 12
0
        public bool InitWithWaves(int wav, float amp, bool h, bool v, CCGridSize gridSize, float duration)
        {
            if (base.InitWithSize(gridSize, duration))
            {
                m_nWaves = wav;
                m_fAmplitude = amp;
                m_fAmplitudeRate = 1.0f;
                m_bHorizontal = h;
                m_bVertical = v;

                return true;
            }

            return false;
        }
Exemplo n.º 13
0
        public bool InitWithPosition(CCPoint pos, int t, float amp, CCGridSize gridSize,
                                     float duration)
        {
            if (base.InitWithSize(gridSize, duration))
            {
                m_positionInPixels = new CCPoint();
                Position = pos;
                m_nTwirls = t;
                m_fAmplitude = amp;
                m_fAmplitudeRate = 1.0f;

                return true;
            }

            return false;
        }
Exemplo n.º 14
0
        public bool InitWithPosition(CCPoint pos, float r, CCGridSize gridSize, float duration)
        {
            if (base.InitWithSize(gridSize, duration))
            {
                m_position = new CCPoint(-1, -1);
                m_positionInPixels = new CCPoint();

                Position = pos;
                m_fRadius = r;
                m_fLensEffect = 0.7f;
                m_bDirty = true;

                return true;
            }

            return false;
        }
Exemplo n.º 15
0
        public bool InitWithPosition(CCPoint pos, float r, int wav, float amp,
                                     CCGridSize gridSize, float duration)
        {
            if (base.InitWithSize(gridSize, duration))
            {
                m_positionInPixels = new CCPoint();

                Position = pos;
                m_fRadius = r;
                m_nWaves = wav;
                m_fAmplitude = amp;
                m_fAmplitudeRate = 1.0f;

                return true;
            }

            return false;
        }
Exemplo n.º 16
0
        public void SetTile(Color tile, CCGridSize position)
        {
            Debug.Assert(m_pTGAInfo != null, "tgaInfo must not be nil");
            Debug.Assert(m_pPosToAtlasIndex != null, "posToAtlasIndex must not be nil");
            Debug.Assert(position.X < m_pTGAInfo.width, "Invalid position.x");
            Debug.Assert(position.Y < m_pTGAInfo.height, "Invalid position.x");
            Debug.Assert(tile.R != 0, "R component must be non 0");

            Color value = m_pTGAInfo.imageData[position.X + position.Y * m_pTGAInfo.width];
            if (value.R == 0)
            {
                CCLog.Log("cocos2d: Value.r must be non 0.");
            }
            else
            {
                m_pTGAInfo.imageData[position.X + position.Y * m_pTGAInfo.width] = tile;

                // XXX: this method consumes a lot of memory
                // XXX: a tree of something like that shall be impolemented
                int num = m_pPosToAtlasIndex[position];
                UpdateAtlasValueAt(position, tile, num);
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// creates the action with the grid size and the duration
 /// </summary>
 public static new CCFadeOutTRTiles Create(CCGridSize gridSize, float time)
 {
     var pAction = new CCFadeOutTRTiles();
     pAction.InitWithSize(gridSize, time);
     return pAction;
 }
Exemplo n.º 18
0
        /// <summary>
        ///  returns the tile at the given position
        /// </summary>
        public CCQuad3 Tile(CCGridSize pos)
        {
            int idx = (m_sGridSize.Y * pos.X + pos.Y) * 4;

            ccV3F_T2F[] vertArray = m_pVertices;

            return new CCQuad3
                {
                    BottomLeft = vertArray[idx + 0].vertices,
                    BottomRight = vertArray[idx + 1].vertices,
                    TopLeft = vertArray[idx + 2].vertices,
                    TopRight = vertArray[idx + 3].vertices
                };
        }
Exemplo n.º 19
0
 /// <summary>
 /// returns the original tile (untransformed) at the given position
 /// </summary>
 public CCQuad3 OriginalTile(CCGridSize pos)
 {
     int idx = (m_sGridSize.Y * pos.X + pos.Y);
     return m_pOriginalVertices[idx];
 }
Exemplo n.º 20
0
        /// <summary>
        /// sets a new tile
        /// </summary>
        public void SetTile(CCGridSize pos, ref CCQuad3 coords)
        {
            int idx = (m_sGridSize.Y * pos.X + pos.Y) * 4;

            ccV3F_T2F[] vertArray = m_pVertices;

            vertArray[idx + 0].vertices = coords.BottomLeft;
            vertArray[idx + 1].vertices = coords.BottomRight;
            vertArray[idx + 2].vertices = coords.TopLeft;
            vertArray[idx + 3].vertices = coords.TopRight;

            m_bDirty = true;
        }
Exemplo n.º 21
0
        //! helper function to create a ccGridSize
        public static CCGridSize GridSize(int x, int y)
        {
            CCGridSize v = new CCGridSize(x, y);

            return(v);
        }
Exemplo n.º 22
0
        public override void Update(float time)
        {
            float angle = (float) Math.PI * time; // 180 degrees
            var mz = (float) Math.Sin(angle);
            angle = angle / 2.0f; // x calculates degrees from 0 to 90
            var mx = (float) Math.Cos(angle);

            CCVertex3F v0, v1, v;
            var diff = new CCVertex3F();

            v0 = OriginalVertex(new CCGridSize(1, 1));
            v1 = OriginalVertex(new CCGridSize(0, 0));

            float x0 = v0.X;
            float x1 = v1.X;
            float x;
            CCGridSize a, b, c, d;

            if (x0 > x1)
            {
                // Normal Grid
                a = new CCGridSize(0, 0);
                b = new CCGridSize(0, 1);
                c = new CCGridSize(1, 0);
                d = new CCGridSize(1, 1);
                x = x0;
            }
            else
            {
                // Reversed Grid
                c = new CCGridSize(0, 0);
                d = new CCGridSize(0, 1);
                a = new CCGridSize(1, 0);
                b = new CCGridSize(1, 1);
                x = x1;
            }

            diff.X = (x - x * mx);
            diff.Z = Math.Abs((float) Math.Floor((x * mz) / 4.0f));

            // bottom-left
            v = OriginalVertex(a);
            v.X = diff.X;
            v.Z += diff.Z;
            SetVertex(a, ref v);

            // upper-left
            v = OriginalVertex(b);
            v.X = diff.X;
            v.Z += diff.Z;
            SetVertex(b, ref v);

            // bottom-right
            v = OriginalVertex(c);
            v.X -= diff.X;
            v.Z -= diff.Z;
            SetVertex(c, ref v);

            // upper-right
            v = OriginalVertex(d);
            v.X -= diff.X;
            v.Z -= diff.Z;
            SetVertex(d, ref v);
        }
Exemplo n.º 23
0
 public CCWaves(int wav, float amp, bool h, bool v, CCGridSize gridSize, float duration)
     : base(duration)
 {
     InitWithWaves(wav, amp, h, v, gridSize, duration);
 }
Exemplo n.º 24
0
 public static CCWaves Create(int wav, float amp, bool h, bool v, CCGridSize gridSize, float duration)
 {
     var pAction = new CCWaves();
     pAction.InitWithWaves(wav, amp, h, v, gridSize, duration);
     return pAction;
 }
Exemplo n.º 25
0
 public CCJumpTiles3D(int j, float amp, CCGridSize gridSize, float duration)
     : base(duration)
 {
     InitWithJumps(j, amp, gridSize, duration);
 }
Exemplo n.º 26
0
 public CCWaves3D(int wav, float amp, CCGridSize gridSize, float duration)
     : base(duration)
 {
     InitWithWaves(wav, amp, gridSize, duration);
 }
Exemplo n.º 27
0
        /// <summary>
        /// initializes the action with the number of jumps, the sin amplitude, the grid size and the duration 
        /// </summary>
        protected virtual bool InitWithJumps(int j, float amp, CCGridSize gridSize, float duration)
        {
            if (base.InitWithSize(gridSize, duration))
            {
                m_nJumps = j;
                m_fAmplitude = amp;
                m_fAmplitudeRate = 1.0f;

                return true;
            }

            return false;
        }
Exemplo n.º 28
0
 public void TurnOnTile(CCGridSize pos)
 {
     CCQuad3 orig = OriginalTile(pos);
     SetTile(pos, ref orig);
 }
Exemplo n.º 29
0
 public void TurnOffTile(CCGridSize pos)
 {
     var coords = new CCQuad3();
     //memset(&coords, 0, sizeof(ccQuad3));
     SetTile(pos, ref coords);
 }
Exemplo n.º 30
0
 public CCPageTurn3D(CCGridSize gridSize, float time)
 {
     InitWithSize(gridSize, time);
 }
Exemplo n.º 31
0
 /// <summary>
 /// creates the action with the grid size and the duration
 /// </summary>
 public CCFadeOutBLTiles(CCGridSize gridSize, float time)
     : base(time)
 {
     InitWithSize(gridSize, time);
 }