Android Open Source - balance-it Tile






From Project

Back to project page balance-it.

License

The source code is released under:

Apache License

If you think the Android project balance-it 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.example.balanceit;
//from   w w  w  . j a  va  2 s  . c  o m
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

/**
 * Die Tile-Klasse reprsentiert eine Kachel der Spielwelt.
 * Sie speichert Informationen zu Typ, Position und Darstellung der Kachel.
 */
public class Tile {

    /** ENUM-Typ fr die Form des Kachelobjekts: quadratisch/kreisfrmig */
    enum Type {SQUARE,CIRCLE};

    public Type mType;
    int mPosX;
    int mPosY;
    int mTileSize;
    Bitmap mBitmap;
    Paint mPaintBlue;
    Paint mPaintGray;

    //TODO AP Welt: weitere Membervariablen (mPosX, mPosY, mBitmap) 

    /** Konstruktor
     * @param type Art der Kachel (Rechteck, Kreis)
     * @param x Position X
     * @param y Position Y
     * @param size Kachelgre
     * @param bitmap Bitmap des Kachelobjekts
     */
    Tile (Type type, int x, int y, int tileSize, Bitmap bitmap){
      mType=type;
      mPosX=x;
      mPosY=y;
      mTileSize=tileSize;
      mBitmap=bitmap;
      mPaintBlue=new Paint();
      mPaintBlue.setColor(Color.BLUE);
      mPaintGray=new Paint();
      mPaintGray.setColor(Color.GRAY);

    }

    /** zeichne die Kachelbitmap an der Position mPosX/Y
     * @param canvas Leinwand
     */
    void draw(Canvas canvas){
        if (mBitmap==null){
          if (mType==Type.SQUARE)
            canvas.drawRect(mPosX,mPosY,mPosX+mTileSize,mPosY+mTileSize, mPaintGray);
          else
            canvas.drawCircle(mPosX+mTileSize/2,mPosY+mTileSize/2,mTileSize/2,mPaintBlue);            
        } else          
          canvas.drawBitmap(mBitmap,mPosX,mPosY,null);
        
    }
}




Java Source Code List

com.example.balanceit.Ball.java
com.example.balanceit.FXHelper.java
com.example.balanceit.GameActivity.java
com.example.balanceit.GravitySensorListener.java
com.example.balanceit.InfoActivity.java
com.example.balanceit.StartActivity.java
com.example.balanceit.Tile.java
com.example.balanceit.World.java