@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); // Create a text view supposed to display tuto messages if (mTutoTextView == null) { mTutoTextView = new TextView(getContext()); mTutoTextView.setTextAppearance(getContext(), android.R.style.TextAppearance_Large); mTutoTextView.setTextColor(getResources().getColor(R.color.white)); mTutoTextView.setTypeface(null, Typeface.BOLD); mTutoTextView.setBackgroundResource(R.color.alpha_shadow); mTutoTextView.setGravity(Gravity.CENTER); final int padding = getResources().getDimensionPixelSize(R.dimen.default_padding); mTutoTextView.setPadding(padding, 2 * padding, padding, padding); final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); mTutoTextView.setLayoutParams(layoutParams); } mAnimationLayer.addView(mTutoTextView); displayCurrentStepMessage(false); }
@Override public void onDrawing(Canvas c) { super.onDrawing(c); int step = mGameEngine.getCurrentStep(); resetPainter(); if (step >= GameInformationTutorial.STEP_CROSSHAIR) { drawCrossHair(c); } if (step >= GameInformationTutorial.STEP_COMBO) { drawCombo(c); } if (step >= GameInformationTutorial.STEP_AMMO) { drawAmmo(c); } if (step >= GameInformationTutorial.STEP_SCORE) { drawScore(c); } }
@Override protected void onDetachedFromWindow() { mAnimationLayer.removeView(mTutoTextView); super.onDetachedFromWindow(); }