public static CCBValue Create(byte[] pointer) { var ret = new CCBValue(); ret.pointer = pointer; ret.mType = ValueType.kPointerValue; return ret; }
public static CCBValue Create(byte bValue) { var ret = new CCBValue(); ret.nValue = bValue; ret.mType = ValueType.kUnsignedCharValue; return ret; }
public static CCBValue Create(float fValue) { var ret = new CCBValue(); ret.fValue = fValue; ret.mType = ValueType.kFloatValue; return ret; }
public static CCBValue Create(bool bValue) { var ret = new CCBValue(); ret.nValue = bValue ? 1 : 0; ret.mType = ValueType.kBoolValue; return ret; }
public static CCBValue Create(int nValue) { var ret = new CCBValue(); ret.nValue = nValue; ret.mType = ValueType.kIntValue; return ret; }
private CCBKeyframe ReadKeyframe(kCCBPropType type) { var keyframe = new CCBKeyframe(); keyframe.Time = ReadFloat(); var easingType = (kCCBKeyframeEasing) ReadInt(false); float easingOpt = 0; object value = null; if (easingType == kCCBKeyframeEasing.kCCBKeyframeEasingCubicIn || easingType == kCCBKeyframeEasing.kCCBKeyframeEasingCubicOut || easingType == kCCBKeyframeEasing.kCCBKeyframeEasingCubicInOut || easingType == kCCBKeyframeEasing.kCCBKeyframeEasingElasticIn || easingType == kCCBKeyframeEasing.kCCBKeyframeEasingElasticOut || easingType == kCCBKeyframeEasing.kCCBKeyframeEasingElasticInOut) { easingOpt = ReadFloat(); } keyframe.EasingType = easingType; keyframe.EasingOpt = easingOpt; if (type == kCCBPropType.kCCBPropTypeCheck) { value = new CCBValue(ReadBool()); } else if (type == kCCBPropType.kCCBPropTypeByte) { value = new CCBValue(ReadByte()); } else if (type == kCCBPropType.kCCBPropTypeColor3) { byte r = ReadByte(); byte g = ReadByte(); byte b = ReadByte(); var c = new CCColor3B(r, g, b); value = ccColor3BWapper.Create(c); } else if (type == kCCBPropType.kCCBPropTypeDegrees) { value = new CCBValue(ReadFloat()); } else if (type == kCCBPropType.kCCBPropTypeScaleLock || type == kCCBPropType.kCCBPropTypePosition) { float a = ReadFloat(); float b = ReadFloat(); value = new List<CCBValue> { new CCBValue(a), new CCBValue(b) }; } else if (type == kCCBPropType.kCCBPropTypeSpriteFrame) { 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 = CCSpriteFrame.Create(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 float ParsePropTypeDegrees(CCNode node, CCNode parent, CCBReader reader, string propertyName) { float ret = reader.ReadFloat(); if (reader.AnimatedProperties.Contains(propertyName)) { CCBValue value = new CCBValue(ret); reader.AnimationManager.SetBaseValue(value, node, propertyName); } return ret; }
protected virtual bool ParsePropTypeCheck(CCNode node, CCNode parent, CCBReader reader, string propertyName) { bool ret = reader.ReadBool(); if (reader.AnimatedProperties.Contains(propertyName)) { CCBValue value = new CCBValue(ret); reader.AnimationManager.SetBaseValue(value, node, propertyName); } return ret; }