Example #1
0
        public IntroLayer()
            : base(CCColor4B.Gray)
        {
            titleLabel = new CCLabel("CocosJuce", "fonts/Roboto-Light-72.fnt");
            frequencyLabel = new CCLabel("", "fonts/Roboto-Light-72.fnt");

            onOffSwitchSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
            onOffSwitchSpriteFrameCache.AddSpriteFrames("images/onoffswitch.plist");

            switchOnSprite = new CCSprite("switch_on.png");
            switchOffSprite = new CCSprite("switch_off.png");
            onOffSwitch = new CCMenuItemToggle(SwitchToggle, new CCMenuItem[]
                                                         {
                                                             new CCMenuItemImage(switchOffSprite) { },
                                                             new CCMenuItemImage(switchOnSprite) { },
                                                         });

            menu = new CCMenu(onOffSwitch);

            freqKnobSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
            freqKnobSpriteFrameCache.AddSpriteFrames("images/frequencyknob.plist");

            frequencyKnob = new CCSprite("frequencyknob00.png");

            AddChild(titleLabel);
            AddChild(menu);
            AddChild(frequencyLabel);
            AddChild(frequencyKnob);
        }
Example #2
0
 public CocoPieceBuilder()
 {
     this.settings = DependencyService.Get<ISetttingsProvider>(DependencyFetchTarget.GlobalInstance);
     this.cache = CCSpriteFrameCache.SharedSpriteFrameCache;
     var set = settings["chess-set"];
     var chessSet = JsonConvert.DeserializeObject<ChessSet>(set);
     if (chessSet != null && !string.IsNullOrEmpty(chessSet.FilePath))
     {
         this.cache.AddSpriteFrames(chessSet.FilePath);
     }
     else
     {
         // default value
         this.cache.AddSpriteFrames("hd/sprites.plist");
     }
 }
Example #3
0
 public static void PurgeSharedSpriteFrameCache()
 {
     sharedSpriteFrameCache = null;
 }
Example #4
0
 public static void PurgeSharedSpriteFrameCache()
 {
     sharedSpriteFrameCache = null;
 }
Example #5
0
        private CCBKeyframe ReadKeyframe(CCBPropertyType type)
        {
            var keyframe = new CCBKeyframe();

            keyframe.Time = ReadFloat();

            var    easingType = (CCBEasingType)ReadInt(false);
            float  easingOpt  = 0;
            object value      = null;

            if (easingType == CCBEasingType.CubicIn ||
                easingType == CCBEasingType.CubicOut ||
                easingType == CCBEasingType.CubicInOut ||
                easingType == CCBEasingType.ElasticIn ||
                easingType == CCBEasingType.ElasticOut ||
                easingType == CCBEasingType.ElasticInOut)
            {
                easingOpt = ReadFloat();
            }
            keyframe.EasingType = easingType;
            keyframe.EasingOpt  = easingOpt;

            if (type == CCBPropertyType.Check)
            {
                value = new CCBValue(ReadBool());
            }
            else if (type == CCBPropertyType.Byte)
            {
                value = new CCBValue(ReadByte());
            }
            else if (type == CCBPropertyType.Color3)
            {
                byte r = ReadByte();
                byte g = ReadByte();
                byte b = ReadByte();

                var c = new CCColor3B(r, g, b);
                value = new CCColor3BWapper(c);
            }
            else if (type == CCBPropertyType.Degrees)
            {
                value = new CCBValue(ReadFloat());
            }
            else if (type == CCBPropertyType.ScaleLock || type == CCBPropertyType.Position || type == CCBPropertyType.FloatXY)
            {
                float a = ReadFloat();
                float b = ReadFloat();

                value = new List <CCBValue>
                {
                    new CCBValue(a),
                    new CCBValue(b)
                };
            }
            else if (type == CCBPropertyType.SpriteFrame)
            {
                string spriteSheet = ReadCachedString();
                string spriteFile  = ReadCachedString();

                CCSpriteFrame spriteFrame;

                if (String.IsNullOrEmpty(spriteSheet))
                {
                    spriteFile = _CCBRootPath + spriteFile;

                    CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(CCFileUtils.RemoveExtension(spriteFile));
                    var         bounds  = new CCRect(0, 0, texture.ContentSizeInPixels.Width, texture.ContentSizeInPixels.Height);
                    spriteFrame = new CCSpriteFrame(texture, bounds);
                }
                else
                {
                    spriteSheet = _CCBRootPath + spriteSheet;
                    CCSpriteFrameCache frameCache = CCSpriteFrameCache.SharedSpriteFrameCache;

                    // Load the sprite sheet only if it is not loaded
                    if (!_loadedSpriteSheets.Contains(spriteSheet))
                    {
                        frameCache.AddSpriteFrames(spriteSheet);
                        _loadedSpriteSheets.Add(spriteSheet);
                    }

                    spriteFrame = frameCache[spriteFile];
                }
                value = spriteFrame;
            }

            keyframe.Value = value;

            return(keyframe);
        }