Beispiel #1
0
        protected int m_uAtlasIndex;                    // Absolute (real) Index on the SpriteSheet

        public override void Serialize(System.IO.Stream stream)
        {
            base.Serialize(stream);
            StreamWriter sw = new StreamWriter(stream);

            CCSerialization.SerializeData(Dirty, sw);
            CCSerialization.SerializeData(IsTextureRectRotated, sw);
            CCSerialization.SerializeData(AtlasIndex, sw);
            CCSerialization.SerializeData(TextureRect, sw);
            CCSerialization.SerializeData(OffsetPosition, sw);
            sw.WriteLine(m_TextureFile == null ? "null" : m_TextureFile);
        }
Beispiel #2
0
        public override void Deserialize(System.IO.Stream stream)
        {
            base.Deserialize(stream);
            StreamReader sr = new StreamReader(stream);

            m_TextureFile = sr.ReadLine();
            if (m_TextureFile == "null")
            {
                m_TextureFile = null;
            }
            else
            {
                CCLog.Log("CCSprite - deserialized with texture file " + m_TextureFile);
                InitWithFile(m_TextureFile);
            }
            Dirty = CCSerialization.DeSerializeBool(sr);
            IsTextureRectRotated = CCSerialization.DeSerializeBool(sr);
            AtlasIndex           = CCSerialization.DeSerializeInt(sr);
            TextureRect          = CCSerialization.DeSerializeRect(sr);
            OffsetPosition       = CCSerialization.DeSerializePoint(sr);
        }
        /// <summary>
        /// Tells the screen to serialize its state into the given stream.
        /// </summary>
        public virtual void Serialize(Stream stream)
        {
            StreamWriter sw = new StreamWriter(stream);

            CCSerialization.SerializeData(m_bVisible, sw);
            CCSerialization.SerializeData(m_fRotationX, sw);
            CCSerialization.SerializeData(m_fRotationY, sw);
            CCSerialization.SerializeData(m_fScaleX, sw);
            CCSerialization.SerializeData(m_fScaleY, sw);
            CCSerialization.SerializeData(m_fSkewX, sw);
            CCSerialization.SerializeData(m_fSkewY, sw);
            CCSerialization.SerializeData(m_fVertexZ, sw);
            CCSerialization.SerializeData(m_bIgnoreAnchorPointForPosition, sw);
            CCSerialization.SerializeData(m_bInverseDirty, sw);
            CCSerialization.SerializeData(m_bRunning, sw);
            CCSerialization.SerializeData(m_bTransformDirty, sw);
            CCSerialization.SerializeData(m_bReorderChildDirty, sw);
            CCSerialization.SerializeData(m_uOrderOfArrival, sw);
            CCSerialization.SerializeData(m_nTag, sw);
            CCSerialization.SerializeData(m_nZOrder, sw);
            CCSerialization.SerializeData(m_obAnchorPoint, sw);
            CCSerialization.SerializeData(m_obContentSize, sw);
            CCSerialization.SerializeData(Position, sw);
            if (m_pChildren != null)
            {
                CCSerialization.SerializeData(m_pChildren.Count, sw);
                foreach (CCNode child in m_pChildren)
                {
                    sw.WriteLine(child.GetType().AssemblyQualifiedName);
                }
                foreach (CCNode child in m_pChildren)
                {
                    child.Serialize(stream);
                }
            }
            else
            {
                CCSerialization.SerializeData(0, sw); // No children
            }
        }
        /// <summary>
        /// Tells the screen to deserialize its state from the given stream.
        /// </summary>
        public virtual void Deserialize(Stream stream)
        {
            StreamReader sr = new StreamReader(stream);

            m_bVisible   = CCSerialization.DeSerializeBool(sr);
            m_fRotationX = CCSerialization.DeSerializeFloat(sr);
            m_fRotationY = CCSerialization.DeSerializeFloat(sr);
            m_fScaleX    = CCSerialization.DeSerializeFloat(sr);
            m_fScaleY    = CCSerialization.DeSerializeFloat(sr);
            m_fSkewX     = CCSerialization.DeSerializeFloat(sr);
            m_fSkewY     = CCSerialization.DeSerializeFloat(sr);
            m_fVertexZ   = CCSerialization.DeSerializeFloat(sr);
            m_bIgnoreAnchorPointForPosition = CCSerialization.DeSerializeBool(sr);
            m_bInverseDirty      = CCSerialization.DeSerializeBool(sr);
            m_bRunning           = CCSerialization.DeSerializeBool(sr);
            m_bTransformDirty    = CCSerialization.DeSerializeBool(sr);
            m_bReorderChildDirty = CCSerialization.DeSerializeBool(sr);
            m_uOrderOfArrival    = (uint)CCSerialization.DeSerializeInt(sr);
            m_nTag      = CCSerialization.DeSerializeInt(sr);
            m_nZOrder   = CCSerialization.DeSerializeInt(sr);
            AnchorPoint = CCSerialization.DeSerializePoint(sr);
            ContentSize = CCSerialization.DeSerializeSize(sr);
            Position    = CCSerialization.DeSerializePoint(sr);
            // m_UserData is handled by the specialized class.
            // TODO: Serializze the action manager
            // TODO :Serialize the grid
            // TODO: Serialize the camera
            string s;
            int    count = CCSerialization.DeSerializeInt(sr);

            for (int i = 0; i < count; i++)
            {
                s = sr.ReadLine();
                Type   screenType = Type.GetType(s);
                CCNode scene      = Activator.CreateInstance(screenType) as CCNode;
                AddChild(scene);
                scene.Deserialize(stream);
            }
        }