public Ship() { mPaint = new Paint(); mPaint.setStyle(Style.FILL); setPosition(getWidth() * 0.5f, getHeight() * 0.5f); setVelocity(0, 0); setSize(mShipSize); mPath = new Path(); mPath.moveTo(0, 0); mPath.lineTo((float)Math.cos(-CORNER_ANGLE) * mSize, (float)Math.sin(-CORNER_ANGLE) * mSize); mPath.lineTo(mSize, 0); mPath.lineTo((float)Math.cos(CORNER_ANGLE) * mSize, (float)Math.sin(CORNER_ANGLE) * mSize); mPath.lineTo(0, 0); }
public Ship() { mPaint = new Paint(); mPaint.setStyle(Style.FILL); setPosition(getWidth() * 0.5f, getHeight() * 0.5f); setVelocity(0, 0); setSize(mShipSize); mPath = new Path(); mPath.moveTo(0, 0); mPath.lineTo((float)Math.cos(-CORNER_ANGLE) * mSize, (float)Math.sin(-CORNER_ANGLE) * mSize); mPath.lineTo(mSize, 0); mPath.lineTo((float)Math.cos(CORNER_ANGLE) * mSize, (float)Math.sin(CORNER_ANGLE) * mSize); mPath.lineTo(0, 0); }
@Override public void onWindowFocusChanged(boolean hasWindowFocus) { // Turn on and off animations based on the window focus. // Alternately, we could update the game state using the Activity onResume() // and onPause() lifecycle events. if (hasWindowFocus) { getHandler().postDelayed(mAnimationRunnable, ANIMATION_TIME_STEP); mLastStepTime = SystemClock.uptimeMillis(); } else { getHandler().removeCallbacks(mAnimationRunnable); mDPadState = 0; if (mShip != null) { mShip.setHeading(0, 0); mShip.setVelocity(0, 0); } } super.onWindowFocusChanged(hasWindowFocus); }
@Override public void onWindowFocusChanged(boolean hasWindowFocus) { // Turn on and off animations based on the window focus. // Alternately, we could update the game state using the Activity onResume() // and onPause() lifecycle events. if (hasWindowFocus) { getHandler().postDelayed(mAnimationRunnable, ANIMATION_TIME_STEP); mLastStepTime = SystemClock.uptimeMillis(); } else { getHandler().removeCallbacks(mAnimationRunnable); mDPadState = 0; if (mShip != null) { mShip.setHeading(0, 0); mShip.setVelocity(0, 0); } } super.onWindowFocusChanged(hasWindowFocus); }