Android Open Source - TheNewBoston My Bring Back






From Project

Back to project page TheNewBoston.

License

The source code is released under:

Eclipse Public License - v 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECI...

If you think the Android project TheNewBoston listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.homelysoft.thenewboston.gfx;
/*ww w  .  j  av a  2 s.  co  m*/
import javax.vecmath.Point3f;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.view.View;

import com.homelysoft.thenewboston.R;

public class MyBringBack extends View {

  Bitmap ball;
  Point3f pos, vel, acce;

  Rect rect;
  Paint paint, fontPaint;

  Typeface font;

  public MyBringBack(Context context) {
    super(context);
    ball = BitmapFactory.decodeResource(getResources(), R.drawable.b_ball);
    pos = new Point3f(200, 500, 0);
    vel = new Point3f(0, 10, 0);
    acce = new Point3f(0, 1, 0);
    rect = new Rect();
    paint = new Paint();
    paint.setColor(Color.RED);
    fontPaint = new Paint();
    fontPaint.setARGB(100, 100, 0, 100);
    fontPaint.setTextAlign(Align.CENTER);
    fontPaint.setTextSize(25);
    font = Typeface.createFromAsset(context.getAssets(), "lazy.ttf");
    fontPaint.setTypeface(font);

  }

  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.drawColor(Color.GREEN);

    canvas.drawText(vel.toString(), pos.getX(), pos.getY(), fontPaint);

    canvas.drawBitmap(ball, canvas.getWidth() / 2, pos.getY(), null);

    pos.add(vel);
    vel.add(acce);
    
    if (pos.getY() + ball.getHeight()/2 >= canvas.getHeight()) {
      vel.negate();
    }

    rect.set(0, (int) (canvas.getHeight() * 0.4), canvas.getWidth(),
        (int) (canvas.getHeight() * 0.6));

    canvas.drawRect(rect, paint);

    invalidate();
  }
}




Java Source Code List

com.homelysoft.thenewboston.AboutUs.java
com.homelysoft.thenewboston.Accelerate.java
com.homelysoft.thenewboston.Data.java
com.homelysoft.thenewboston.Email.java
com.homelysoft.thenewboston.ExternalData.java
com.homelysoft.thenewboston.Flipper.java
com.homelysoft.thenewboston.Home.java
com.homelysoft.thenewboston.HotOrNot.java
com.homelysoft.thenewboston.InternalData.java
com.homelysoft.thenewboston.OpenedClass.java
com.homelysoft.thenewboston.OurViewClient.java
com.homelysoft.thenewboston.Photo.java
com.homelysoft.thenewboston.Preferences.java
com.homelysoft.thenewboston.SQLView.java
com.homelysoft.thenewboston.SQLite.java
com.homelysoft.thenewboston.SharedPrefs.java
com.homelysoft.thenewboston.Slider.java
com.homelysoft.thenewboston.SoundPoolPlay.java
com.homelysoft.thenewboston.Splash.java
com.homelysoft.thenewboston.StartingPoint.java
com.homelysoft.thenewboston.Tabs.java
com.homelysoft.thenewboston.TextPlay.java
com.homelysoft.thenewboston.gfx.GFXSurface.java
com.homelysoft.thenewboston.gfx.GFX.java
com.homelysoft.thenewboston.gfx.MyBringBack.java
com.homelysoft.thenewboston.vect.Vector.java