Ejemplo n.º 1
0
        public void TurnOffTile(CCGridSize pos)
        {
            var coords = new CCQuad3();

            //memset(&coords, 0, sizeof(ccQuad3));
            SetTile(pos, ref coords);
        }
Ejemplo n.º 2
0
        protected virtual bool InitWithSize(CCGridSize gridSize, CCTexture2D pTexture, bool bFlipped)
        {
            bool bRet = true;

            m_bActive = false;
            m_nReuseGrid = 0;
            m_sGridSize = gridSize;

            m_pTexture = pTexture;

            m_bIsTextureFlipped = bFlipped;

            CCSize texSize = m_pTexture.ContentSize;
            m_obStep.X = texSize.Width / m_sGridSize.X;
            m_obStep.Y = texSize.Height / m_sGridSize.Y;

            m_pGrabber = new CCGrabber();
            if (m_pGrabber != null)
            {
                m_pGrabber.Grab(m_pTexture);
            }
            else
            {
                bRet = false;
            }

            //m_pShaderProgram = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture);
            CalculateVertexPoints();

            return bRet;
        }
Ejemplo n.º 3
0
        protected virtual bool InitWithSize(CCGridSize gridSize, CCTexture2D pTexture, bool bFlipped)
        {
            bool bRet = true;

            m_bActive    = false;
            m_nReuseGrid = 0;
            m_sGridSize  = gridSize;

            m_pTexture = pTexture;

            m_bIsTextureFlipped = bFlipped;

            CCSize texSize = m_pTexture.ContentSize;

            m_obStep.X = texSize.Width / m_sGridSize.X;
            m_obStep.Y = texSize.Height / m_sGridSize.Y;

            m_pGrabber = new CCGrabber();
            if (m_pGrabber != null)
            {
                m_pGrabber.Grab(m_pTexture);
            }
            else
            {
                bRet = false;
            }

            //m_pShaderProgram = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture);
            CalculateVertexPoints();

            return(bRet);
        }
Ejemplo n.º 4
0
        public override void UpdateAtlasValues()
        {
            Debug.Assert(m_pTGAInfo != null, "tgaInfo must be non-nil");

            int total = 0;

            for (int x = 0; x < m_pTGAInfo.width; x++)
            {
                for (int y = 0; y < m_pTGAInfo.height; y++)
                {
                    if (total < m_nItemsToRender)
                    {
                        Color value = m_pTGAInfo.imageData[x + y * m_pTGAInfo.width];

                        if (value.R != 0)
                        {
                            var pos = new CCGridSize(x, y);
                            UpdateAtlasValueAt(pos, value, total);
                            m_pPosToAtlasIndex.Add(pos, total);

                            total++;
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
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]);
        }
Ejemplo n.º 7
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];
        }
Ejemplo n.º 8
0
        private void UpdateAtlasValueAt(CCGridSize pos, Color value, int index)
        {
            int x = pos.X;
            int y = pos.Y;

            float row = (float)(value.R % m_uItemsPerRow);
            float col = (float)(value.R / m_uItemsPerRow);

            float textureWide = (m_pTextureAtlas.Texture.PixelsWide);
            float textureHigh = (m_pTextureAtlas.Texture.PixelsHigh);

            float itemWidthInPixels  = m_uItemWidth * CCMacros.CCContentScaleFactor();
            float itemHeightInPixels = m_uItemHeight * CCMacros.CCContentScaleFactor();

#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
            float left   = (2 * row * itemWidthInPixels + 1) / (2 * textureWide);
            float right  = left + (itemWidthInPixels * 2 - 2) / (2 * textureWide);
            float top    = (2 * col * itemHeightInPixels + 1) / (2 * textureHigh);
            float bottom = top + (itemHeightInPixels * 2 - 2) / (2 * textureHigh);
#else
            float left   = (row * itemWidthInPixels) / textureWide;
            float right  = left + itemWidthInPixels / textureWide;
            float top    = (col * itemHeightInPixels) / textureHigh;
            float bottom = top + itemHeightInPixels / textureHigh;
#endif

            CCV3F_C4B_T2F_Quad quad;

            quad.TopLeft.TexCoords.U     = left;
            quad.TopLeft.TexCoords.V     = top;
            quad.TopRight.TexCoords.U    = right;
            quad.TopRight.TexCoords.V    = top;
            quad.BottomLeft.TexCoords.U  = left;
            quad.BottomLeft.TexCoords.V  = bottom;
            quad.BottomRight.TexCoords.U = right;
            quad.BottomRight.TexCoords.V = bottom;

            quad.BottomLeft.Vertices.X  = (x * m_uItemWidth);
            quad.BottomLeft.Vertices.Y  = (y * m_uItemHeight);
            quad.BottomLeft.Vertices.Z  = 0.0f;
            quad.BottomRight.Vertices.X = (x * m_uItemWidth + m_uItemWidth);
            quad.BottomRight.Vertices.Y = (y * m_uItemHeight);
            quad.BottomRight.Vertices.Z = 0.0f;
            quad.TopLeft.Vertices.X     = (x * m_uItemWidth);
            quad.TopLeft.Vertices.Y     = (y * m_uItemHeight + m_uItemHeight);
            quad.TopLeft.Vertices.Z     = 0.0f;
            quad.TopRight.Vertices.X    = (x * m_uItemWidth + m_uItemWidth);
            quad.TopRight.Vertices.Y    = (y * m_uItemHeight + m_uItemHeight);
            quad.TopRight.Vertices.Z    = 0.0f;

            var color = new CCColor4B(m_tColor.R, m_tColor.G, m_tColor.B, m_cOpacity);
            quad.TopRight.Colors    = color;
            quad.TopLeft.Colors     = color;
            quad.BottomRight.Colors = color;
            quad.BottomLeft.Colors  = color;

            m_pTextureAtlas.UpdateQuad(ref quad, index);
        }
Ejemplo n.º 9
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);
                }
            }
        }
Ejemplo n.º 10
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);
                }
            }
        }
Ejemplo n.º 11
0
 protected virtual bool InitWithSize(CCGridSize gridSize, float duration)
 {
     if (base.InitWithDuration(duration))
     {
         m_sGridSize = gridSize;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 12
0
 protected virtual bool InitWithSize(CCGridSize gridSize, float duration)
 {
     if (base.InitWithDuration(duration))
     {
         m_sGridSize = gridSize;
         return true;
     }
     return false;
 }
Ejemplo n.º 13
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.Y == 0)
            {
                return 1.0f;
            }

            return (float) Math.Pow(n.Y / pos.Y, 6);
        }
Ejemplo n.º 14
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));
        }
Ejemplo n.º 15
0
        protected virtual bool InitWithSize(CCGridSize gridSize, CCSize size)
        {
            var pTexture = new CCTexture2D();

            // we only use rgba8888
            pTexture.Init((int)size.Width, (int)size.Height, SurfaceFormat.Color, true);

            InitWithSize(gridSize, pTexture, false);

            return(true);
        }
Ejemplo n.º 16
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;
 }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
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));
        }
Ejemplo n.º 19
0
 public bool InitWithWaves(float duration, CCGridSize gridSize, int waves, float amplitude)
 {
     if (InitWithDuration(duration, gridSize))
     {
         m_nWaves = waves;
         m_fAmplitude = amplitude;
         m_fAmplitudeRate = 1.0f;
         return true;
     }
     return false;
 }
Ejemplo n.º 20
0
        protected 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);
        }
Ejemplo n.º 21
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);
 }
Ejemplo n.º 22
0
 public bool InitWithWaves(float duration, CCGridSize gridSize, int waves, float amplitude)
 {
     if (InitWithDuration(duration, gridSize))
     {
         m_nWaves         = waves;
         m_fAmplitude     = amplitude;
         m_fAmplitudeRate = 1.0f;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 23
0
        protected override bool InitWithDuration(float duration, CCGridSize gridSize)
        {
            if (gridSize.X != 1 || gridSize.Y != 1)
            {
                // Grid size must be (1,1)
                Debug.Assert(false);
                return(false);
            }

            return(base.InitWithDuration(duration, gridSize));
        }
Ejemplo n.º 24
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));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// initializes the action with the number of jumps, the sin amplitude, the grid size and the duration
        /// </summary>
        protected virtual bool InitWithDuration(float duration, CCGridSize gridSize, int numberOfJumps, float amplitude)
        {
            if (base.InitWithDuration(duration, gridSize))
            {
                m_nJumps         = numberOfJumps;
                m_fAmplitude     = amplitude;
                m_fAmplitudeRate = 1.0f;

                return(true);
            }

            return(false);
        }
Ejemplo n.º 26
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;
        }
Ejemplo 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);
        }
Ejemplo n.º 28
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;
        }
Ejemplo n.º 29
0
        /// <summary>
        ///  initializes the action with a number of waves, the waves amplitude, the grid size and the duration 
        /// </summary>
        protected virtual bool InitWithDuration(float duration, CCGridSize gridSize, int waves, float amplitude)
        {
            if (base.InitWithDuration(duration, gridSize))
            {
                m_nWaves = waves;
                m_fAmplitude = amplitude;
                m_fAmplitudeRate = 1.0f;

                return true;
            }

            return false;
        }
Ejemplo n.º 30
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;
        }
Ejemplo n.º 31
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
            });
        }
Ejemplo n.º 32
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);
        }
Ejemplo n.º 33
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);
        }
Ejemplo n.º 34
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
                };
        }
Ejemplo n.º 35
0
        protected virtual 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;
        }
Ejemplo n.º 36
0
        protected virtual 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);
        }
Ejemplo n.º 37
0
        protected virtual bool initWithDuration(float duration, CCGridSize gridSize, CCPoint position, int twirls,
                                                float amplitude)
        {
            if (base.InitWithDuration(duration, gridSize))
            {
                m_positionInPixels = new CCPoint();
                Position = position;
                m_nTwirls = twirls;
                m_fAmplitude = amplitude;
                m_fAmplitudeRate = 1.0f;

                return true;
            }

            return false;
        }
Ejemplo n.º 38
0
        protected virtual bool initWithDuration(float duration, CCGridSize gridSize, CCPoint position, int twirls,
                                                float amplitude)
        {
            if (base.InitWithDuration(duration, gridSize))
            {
                m_positionInPixels = new CCPoint();
                Position           = position;
                m_nTwirls          = twirls;
                m_fAmplitude       = amplitude;
                m_fAmplitudeRate   = 1.0f;

                return(true);
            }

            return(false);
        }
Ejemplo n.º 39
0
        protected virtual 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);
        }
Ejemplo n.º 40
0
        protected virtual 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;
        }
Ejemplo n.º 41
0
        protected virtual bool InitWithDuration(float duration, CCGridSize gridSize, int waves, float amplitude,
                                                bool horizontal, bool vertical)
        {
            if (base.InitWithDuration(duration, gridSize))
            {
                m_nWaves = waves;
                m_fAmplitude = amplitude;
                m_fAmplitudeRate = 1.0f;
                m_bHorizontal = horizontal;
                m_bVertical = vertical;

                return true;
            }

            return false;
        }
Ejemplo n.º 42
0
        protected virtual bool InitWithDuration(float duration, CCGridSize gridSize, int waves, float amplitude,
                                                bool horizontal, bool vertical)
        {
            if (base.InitWithDuration(duration, gridSize))
            {
                m_nWaves         = waves;
                m_fAmplitude     = amplitude;
                m_fAmplitudeRate = 1.0f;
                m_bHorizontal    = horizontal;
                m_bVertical      = vertical;

                return(true);
            }

            return(false);
        }
Ejemplo n.º 43
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;
        }
Ejemplo n.º 44
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);
        }
Ejemplo n.º 45
0
        protected virtual bool InitWithDuration(float duration, CCGridSize gridSize, CCPoint position, float radius,
                                                int waves, float amplitude)
        {
            if (base.InitWithDuration(duration, gridSize))
            {
                m_positionInPixels = new CCPoint();

                Position = position;
                m_fRadius = radius;
                m_nWaves = waves;
                m_fAmplitude = amplitude;
                m_fAmplitudeRate = 1.0f;

                return true;
            }

            return false;
        }
Ejemplo n.º 46
0
        protected virtual bool InitWithDuration(float duration, CCGridSize gridSize, CCPoint position, float radius,
                                                int waves, float amplitude)
        {
            if (base.InitWithDuration(duration, gridSize))
            {
                m_positionInPixels = new CCPoint();

                Position         = position;
                m_fRadius        = radius;
                m_nWaves         = waves;
                m_fAmplitude     = amplitude;
                m_fAmplitudeRate = 1.0f;

                return(true);
            }

            return(false);
        }
Ejemplo n.º 47
0
        public bool InitWithDuration(float duration, CCGridSize gridSize, CCPoint position, float radius)
        {
            if (base.InitWithDuration(duration, gridSize))
            {
                m_position = new CCPoint(-1, -1);
                m_positionInPixels = new CCPoint();

                Position = position;
                m_fRadius = radius;
                m_fLensEffect = 0.7f;
                m_bConcave = false;
                m_bDirty = true;

                return true;
            }

            return false;
        }
Ejemplo n.º 48
0
        public bool InitWithDuration(float duration, CCGridSize gridSize, CCPoint position, float radius)
        {
            if (base.InitWithDuration(duration, gridSize))
            {
                m_position         = new CCPoint(-1, -1);
                m_positionInPixels = new CCPoint();

                Position      = position;
                m_fRadius     = radius;
                m_fLensEffect = 0.7f;
                m_bConcave    = false;
                m_bDirty      = true;

                return(true);
            }

            return(false);
        }
Ejemplo n.º 49
0
        protected virtual bool InitWithSize(CCGridSize gridSize, CCSize size)
        {
            //ulong POTWide = ccNextPOT((uint) size.width);
            //ulong POTHigh = ccNextPOT((uint) size.width);
            ulong potWide = (uint)size.Width;
            ulong potHigh = (uint)size.Height;

            // we only use rgba8888
            var format = CCTexture2DPixelFormat.RGBA8888;

            var pTexture = new CCTexture2D();

            pTexture.InitWithData(null, format, (uint)potWide, (uint)potHigh, size);

            InitWithSize(gridSize, pTexture, false);

            return(true);
        }
Ejemplo n.º 50
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);
            }
        }
Ejemplo n.º 51
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);
            }
        }
Ejemplo n.º 52
0
 public CCLiquid (int wav, float amp, CCGridSize gridSize, float duration)
 {
     InitWithWaves(wav, amp, gridSize, duration);
 }
Ejemplo n.º 53
0
        //! helper function to create a ccGridSize
        public static CCGridSize GridSize(int x, int y)
        {
            CCGridSize v = new CCGridSize(x, y);

            return(v);
        }
Ejemplo n.º 54
0
 /// <summary>
 /// creates the action with the grid size and the duration
 /// </summary>
 public CCFadeOutBLTiles(float duration, CCGridSize gridSize) : base(duration)
 {
     InitWithDuration(duration, gridSize);
 }
Ejemplo n.º 55
0
 //! helper function to create a ccGridSize
 public static CCGridSize GridSize(int x, int y)
 {
     CCGridSize v = new CCGridSize(x, y);
     return v;
 }
Ejemplo n.º 56
0
 public CCLiquid(float duration, CCGridSize gridSize, int waves, float amplitude)
 {
     InitWithDuratuon(duration, gridSize, waves, amplitude);
 }
Ejemplo n.º 57
0
        protected virtual bool InitWithSize(CCGridSize gridSize, CCSize size)
        {
            //ulong POTWide = ccNextPOT((uint) size.width);
            //ulong POTHigh = ccNextPOT((uint) size.width);
            ulong potWide = (uint) size.Width;
            ulong potHigh = (uint) size.Height;

            // we only use rgba8888
            var format = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888;

            var pTexture = new CCTexture2D();
            pTexture.InitWithData(null, format, (uint) potWide, (uint) potHigh, size);

            InitWithSize(gridSize, pTexture, false);

            return true;
        }
Ejemplo n.º 58
0
 protected virtual bool InitWithSize(CCGridSize gridSize)
 {
     return InitWithSize(gridSize, CCDirector.SharedDirector.WinSizeInPixels);
 }
Ejemplo n.º 59
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);
        }
Ejemplo n.º 60
0
 public CCTwirl(float duration, CCGridSize gridSize, CCPoint position, int twirls, float amplitude)
     : base(duration)
 {
     initWithDuration(duration, gridSize, position, twirls, amplitude);
 }