Ejemplo n.º 1
0
        /// <summary>
        /// Invoked when the Activity is created.
        /// </summary>
        /// <param name="savedInstanceState"> a Bundle containing state saved from a previous
        ///        execution, or null if this is a new execution </param>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // tell system to use the layout defined in our XML file
            SetContentView(R.Layouts.lunar_layout);

            // get handles to the LunarView from XML, and its LunarThread
            mLunarView   = (LunarView)FindViewById(R.Ids.lunar);
            mLunarThread = mLunarView.Thread;

            // give the LunarView a handle to the TextView used for messages
            mLunarView.TextView = (TextView)FindViewById(R.Ids.text);

            if (savedInstanceState == null)
            {
                // we were just launched: set up a new game
                mLunarThread.state = LunarView.LunarThread.STATE_READY;
                Log.W(GetType().Name, "SIS is null");
            }
            else
            {
                // we are being restored: resume a previous game
                mLunarThread.RestoreState(savedInstanceState);
                Log.W(GetType().Name, "SIS is nonnull");
            }
        }
Ejemplo n.º 2
0
            public LunarThread(LunarView view, ISurfaceHolder surfaceHolder, Context context, Handler handler)
            {
                // get handles to some important objects
                this.view      = view;
                mSurfaceHolder = surfaceHolder;
                mHandler       = handler;
                view.mContext  = context;

                Resources res = context.Resources;

                // cache handles to our key sprites & other drawables
                mLanderImage  = context.Resources.GetDrawable(R.Drawable.lander_plain);
                mFiringImage  = context.Resources.GetDrawable(R.Drawable.lander_firing);
                mCrashedImage = context.Resources.GetDrawable(R.Drawable.lander_crashed);

                // load background image as a Bitmap instead of a Drawable b/c
                // we don't need to transform it and it's faster to draw this way
                mBackgroundImage = BitmapFactory.DecodeResource(res, R.Drawable.earthrise);

                // Use the regular lander image as the model size for all sprites
                mLanderWidth  = mLanderImage.IntrinsicWidth;
                mLanderHeight = mLanderImage.IntrinsicHeight;

                // Initialize paints for speedometer
                mLinePaint             = new Paint();
                mLinePaint.IsAntiAlias = (true);
                mLinePaint.SetARGB(255, 0, 255, 0);

                mLinePaintBad             = new Paint();
                mLinePaintBad.IsAntiAlias = (true);
                mLinePaintBad.SetARGB(255, 120, 180, 0);

                mScratchRect = new RectF(0, 0, 0, 0);

                mWinsInARow = 0;
                mDifficulty = DIFFICULTY_MEDIUM;

                // initial show-up of lander (not yet playing)
                mX            = mLanderWidth;
                mY            = mLanderHeight * 2;
                mFuel         = PHYS_FUEL_INIT;
                mDX           = 0;
                mDY           = 0;
                mHeading      = 0;
                mEngineFiring = true;
            }
Ejemplo n.º 3
0
 public MessageHandler(LunarView view)
 {
     this.view = view;
 }
Ejemplo n.º 4
0
			public LunarThread(LunarView view, ISurfaceHolder surfaceHolder, Context context, Handler handler)
			{
				// get handles to some important objects
			    this.view = view;
			    mSurfaceHolder = surfaceHolder;
				mHandler = handler;
				view.mContext = context;

				Resources res = context.Resources;
				// cache handles to our key sprites & other drawables
				mLanderImage = context.Resources.GetDrawable(R.Drawables.lander_plain);
				mFiringImage = context.Resources.GetDrawable(R.Drawables.lander_firing);
				mCrashedImage = context.GetResources().GetDrawable(R.Drawables.lander_crashed);

				// load background image as a Bitmap instead of a Drawable b/c
				// we don't need to transform it and it's faster to draw this way
				mBackgroundImage = BitmapFactory.DecodeResource(res, R.Drawables.earthrise);

				// Use the regular lander image as the model size for all sprites
				mLanderWidth = mLanderImage.IntrinsicWidth;
				mLanderHeight = mLanderImage.IntrinsicHeight;

				// Initialize paints for speedometer
				mLinePaint = new Paint();
				mLinePaint.SetAntiAlias(true);
				mLinePaint.SetARGB(255, 0, 255, 0);

				mLinePaintBad = new Paint();
				mLinePaintBad.SetAntiAlias(true);
				mLinePaintBad.SetARGB(255, 120, 180, 0);

				mScratchRect = new RectF(0, 0, 0, 0);

				mWinsInARow = 0;
				mDifficulty = DIFFICULTY_MEDIUM;

				// initial show-up of lander (not yet playing)
				mX = mLanderWidth;
				mY = mLanderHeight * 2;
				mFuel = PHYS_FUEL_INIT;
				mDX = 0;
				mDY = 0;
				mHeading = 0;
				mEngineFiring = true;
			}
Ejemplo n.º 5
0
 public MessageHandler(LunarView view)
 {
     this.view = view;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Invoked when the Activity is created.
        /// </summary>
        /// <param name="savedInstanceState"> a Bundle containing state saved from a previous
        ///        execution, or null if this is a new execution </param>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // tell system to use the layout defined in our XML file
            SetContentView(R.Layout.lunar_layout);

            // get handles to the LunarView from XML, and its LunarThread
            mLunarView = (LunarView) FindViewById(R.Id.lunar);
            mLunarThread = mLunarView.Thread;

            // give the LunarView a handle to the TextView used for messages
            mLunarView.TextView = (TextView) FindViewById(R.Id.text);

            if (savedInstanceState == null)
            {
                // we were just launched: set up a new game
                mLunarThread.state = LunarView.LunarThread.STATE_READY;
                Log.W(GetType().Name, "SIS is null");
            }
            else
            {
                // we are being restored: resume a previous game
                mLunarThread.RestoreState(savedInstanceState);
                Log.W(GetType().Name, "SIS is nonnull");
            }
        }