protected virtual CCColor3B ParsePropTypeColor3(CCNode node, CCNode parent, CCBReader reader, string propertyName) { byte red = reader.ReadByte(); byte green = reader.ReadByte(); byte blue = reader.ReadByte(); var color = new CCColor3B(red, green, blue); if (reader.AnimatedProperties.Contains(propertyName)) { ccColor3BWapper value = new ccColor3BWapper(color); reader.AnimationManager.SetBaseValue(value, node, propertyName); } return(color); }
private CCBKeyframe ReadKeyframe(CCBPropType type) { var keyframe = new CCBKeyframe(); keyframe.Time = ReadFloat(); var easingType = (CCBKeyframeEasing) ReadInt(false); float easingOpt = 0; object value = null; if (easingType == CCBKeyframeEasing.CubicIn || easingType == CCBKeyframeEasing.CubicOut || easingType == CCBKeyframeEasing.CubicInOut || easingType == CCBKeyframeEasing.ElasticIn || easingType == CCBKeyframeEasing.ElasticOut || easingType == CCBKeyframeEasing.ElasticInOut) { easingOpt = ReadFloat(); } keyframe.EasingType = easingType; keyframe.EasingOpt = easingOpt; if (type == CCBPropType.Check) { value = new CCBValue(ReadBool()); } else if (type == CCBPropType.Byte) { value = new CCBValue(ReadByte()); } else if (type == CCBPropType.Color3) { byte r = ReadByte(); byte g = ReadByte(); byte b = ReadByte(); var c = new CCColor3B(r, g, b); value = new ccColor3BWapper(c); } else if (type == CCBPropType.Degrees) { value = new CCBValue(ReadFloat()); } else if (type == CCBPropType.ScaleLock || type == CCBPropType.Position) { float a = ReadFloat(); float b = ReadFloat(); value = new List<CCBValue> { new CCBValue(a), new CCBValue(b) }; } else if (type == CCBPropType.SpriteFrame) { string spriteSheet = ReadCachedString(); string spriteFile = ReadCachedString(); CCSpriteFrame spriteFrame; if (String.IsNullOrEmpty(spriteSheet)) { CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(CCFileUtils.RemoveExtension(spriteFile)); var bounds = new CCRect(0, 0, texture.ContentSize.Width, texture.ContentSize.Height); spriteFrame = new CCSpriteFrame(texture, bounds); } else { CCSpriteFrameCache frameCache = CCSpriteFrameCache.SharedSpriteFrameCache; // Load the sprite sheet only if it is not loaded if (!mLoadedSpriteSheets.Contains(spriteSheet)) { frameCache.AddSpriteFramesWithFile(spriteSheet); mLoadedSpriteSheets.Add(spriteSheet); } spriteFrame = frameCache.SpriteFrameByName(spriteFile); } value = spriteFrame; } keyframe.Value = value; return keyframe; }
private CCBKeyframe ReadKeyframe(CCBPropType type) { var keyframe = new CCBKeyframe(); keyframe.Time = ReadFloat(); var easingType = (CCBKeyframeEasing)ReadInt(false); float easingOpt = 0; object value = null; if (easingType == CCBKeyframeEasing.CubicIn || easingType == CCBKeyframeEasing.CubicOut || easingType == CCBKeyframeEasing.CubicInOut || easingType == CCBKeyframeEasing.ElasticIn || easingType == CCBKeyframeEasing.ElasticOut || easingType == CCBKeyframeEasing.ElasticInOut) { easingOpt = ReadFloat(); } keyframe.EasingType = easingType; keyframe.EasingOpt = easingOpt; if (type == CCBPropType.Check) { value = new CCBValue(ReadBool()); } else if (type == CCBPropType.Byte) { value = new CCBValue(ReadByte()); } else if (type == CCBPropType.Color3) { byte r = ReadByte(); byte g = ReadByte(); byte b = ReadByte(); var c = new CCColor3B(r, g, b); value = new ccColor3BWapper(c); } else if (type == CCBPropType.Degrees) { value = new CCBValue(ReadFloat()); } else if (type == CCBPropType.ScaleLock || type == CCBPropType.Position) { float a = ReadFloat(); float b = ReadFloat(); value = new List <CCBValue> { new CCBValue(a), new CCBValue(b) }; } else if (type == CCBPropType.SpriteFrame) { string spriteSheet = ReadCachedString(); string spriteFile = ReadCachedString(); CCSpriteFrame spriteFrame; if (String.IsNullOrEmpty(spriteSheet)) { CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(CCFileUtils.RemoveExtension(spriteFile)); var bounds = new CCRect(0, 0, texture.ContentSize.Width, texture.ContentSize.Height); spriteFrame = new CCSpriteFrame(texture, bounds); } else { CCSpriteFrameCache frameCache = CCSpriteFrameCache.SharedSpriteFrameCache; // Load the sprite sheet only if it is not loaded if (!mLoadedSpriteSheets.Contains(spriteSheet)) { frameCache.AddSpriteFramesWithFile(spriteSheet); mLoadedSpriteSheets.Add(spriteSheet); } spriteFrame = frameCache.SpriteFrameByName(spriteFile); } value = spriteFrame; } keyframe.Value = value; return(keyframe); }
protected virtual CCColor3B ParsePropTypeColor3(CCNode node, CCNode parent, CCBReader reader, string propertyName) { byte red = reader.ReadByte(); byte green = reader.ReadByte(); byte blue = reader.ReadByte(); var color = new CCColor3B(red, green, blue); if (reader.AnimatedProperties.Contains(propertyName)) { ccColor3BWapper value = new ccColor3BWapper(color); reader.AnimationManager.SetBaseValue(value, node, propertyName); } return color; }