Exemple #1
0
        private void SetBackgroundImage()
        {
            Bitmap bitmap = GameUtility.ScaleDown(Resource.Drawable.background, GameUtility.ScreenWidth(), GameUtility.ScreenHeight());

            bitmap = GameUtility.Crop(bitmap, GameUtility.ScreenHeight(), GameUtility.ScreenWidth());
            bitmap = GameUtility.downscaleBitmap(bitmap, 2);
            mBackgroundImage.SetImageBitmap(bitmap);
        }
        /**
         *
         * @param id
         *            The id is the number between 0 and number of possible tiles of
         *            this theme
         * @return The Bitmap of the tile
         */
        public Bitmap getTileBitmap(int id, int size)
        {
            String str = tileUrls[id];

            if (str.Contains(GameThemes.URI_DRAWABLE))
            {
                String drawableResourceName = str.Substring(GameThemes.URI_DRAWABLE.Length);
                int    drawableResourceId   = Application.Context.Resources.GetIdentifier(drawableResourceName, "drawable", Application.Context.PackageName);
                Bitmap bitmap = GameUtility.ScaleDown(drawableResourceId, size, size);
                return(GameUtility.Crop(bitmap, size, size));
            }
            return(null);
        }
        public void onEvent(ThemeSelectedEvent evt)
        {
            mSelectedTheme = evt.theme;
            mScreenController.openScreen(ScreenController.Screen.DIFFICULTY);

            Bitmap bitmap          = GameUtility.ScaleDown(Resource.Drawable.background, GameUtility.ScreenWidth(), GameUtility.ScreenHeight());
            Bitmap backgroundImage = GameThemes.getBackgroundImage(mSelectedTheme);

            backgroundImage = GameUtility.Crop(backgroundImage, GameUtility.ScreenHeight(), GameUtility.ScreenWidth());
            Drawable[] backgrounds = new Drawable[2];
            backgrounds[0] = new BitmapDrawable(Application.Context.Resources, bitmap);
            backgrounds[1] = new BitmapDrawable(Application.Context.Resources, backgroundImage);

            TransitionDrawable crossfader = new TransitionDrawable(backgrounds);

            mBackgroundImage.SetImageDrawable(crossfader);
            crossfader.StartTransition(2000);
        }