コード例 #1
0
ファイル: CCBReader.cs プロジェクト: HarkDev/cocos2d-xna
        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 = new ccColor3BWapper(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 = 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;
        }
コード例 #2
0
ファイル: CCBValue.cs プロジェクト: KogleDK/cocos2d-xna-1
 public static ccColor3BWapper Create(CCColor3B color)
 {
     var ret = new ccColor3BWapper();
     ret.color.R = color.R;
     ret.color.G = color.G;
     ret.color.B = color.B;
     return ret;
 }
コード例 #3
0
ファイル: CCNodeLoader.cs プロジェクト: HarkDev/cocos2d-xna
        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;
        }