BBGamelib.flash.imp.Utils.ReadString C# (CSharp) Method

ReadString() public static method

public static ReadString ( byte data, Cursor cursor ) : string
data byte
cursor Cursor
return string
		public static string ReadString(byte[] data, Cursor cursor)
		{
			int len = Utils.ReadInt32(data, cursor);
			if (len == 0) {
				return null;		
			}
			System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
			string s = enc.GetString(data, cursor.index, len);
			cursor.index += len;
			return s;
		}
		

Usage Example

Beispiel #1
0
        public TagPlaceObject(Flash flash, byte[] data, Cursor cursor)
        {
            this.flash = flash;
            int dataLength = Utils.ReadInt32(data, cursor);
            int nextIndex  = cursor.index + dataLength;

            //parse
            hasMatrix         = Utils.ReadByte(data, cursor) != 0;
            hasMove           = Utils.ReadByte(data, cursor) != 0;
            hasCharacter      = Utils.ReadByte(data, cursor) != 0;
            hasColorTransform = Utils.ReadByte(data, cursor) != 0;
            bool hasName = Utils.ReadByte(data, cursor) != 0;

            hasVisible = Utils.ReadByte(data, cursor) != 0;
            depth      = Utils.ReadInt32(data, cursor);

            if (hasCharacter)
            {
                characterId = Utils.ReadInt32(data, cursor);
            }

            if (hasMatrix)
            {
                position = Utils.ReadVector2(data, cursor);
                rotation = Utils.ReadFloat(data, cursor);
                scaleX   = Utils.ReadFloat(data, cursor);
                scaleY   = Utils.ReadFloat(data, cursor);
            }
            else
            {
                position = Vector2.zero;
                rotation = 0;
                scaleX   = 1;
                scaleY   = 1;
            }
            if (hasVisible)
            {
                visible = Utils.ReadByte(data, cursor) != 0;
            }

            if (hasColorTransform)
            {
                colorTransform = Utils.ReadColorTransform(data, cursor);
            }
            else
            {
                colorTransform = ColorTransform.Default;
            }

            if (hasName)
            {
                instanceName = Utils.ReadString(data, cursor);
            }

            cursor.index = nextIndex;
        }
All Usage Examples Of BBGamelib.flash.imp.Utils::ReadString