Android Open Source - java-androidframework F P S From Project Back to project page java-androidframework .
License The source code is released under:
This project is licensed under the [CC0 1.0 Agreement](http://creativecommons.org/publicdomain/zero/1.0/).
To the extent possible under law, Pete Schmitz has waived all copyright and related or neigh...
If you think the Android project java-androidframework 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.gamepatriot.framework2d.classes;
/ * f r o m w w w . j a v a 2 s . c o m * /
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import com.gamepatriot.framework2d.implementation.Main;
public class FPS {
//Flags
private int second;
private int counter;
private int lastFPS;
//Containers
private final Rect drawRect;
private final Paint paint;
private final Paint paintText;
public FPS(){
int $width = 80;
int $height = 30;
drawRect = new Rect(Main.CANVAS_WIDTH-$width, 0, Main.CANVAS_WIDTH, $height);
paint = new Paint();
paint.setColor(Color.BLACK);
paintText = new Paint();
paintText.setColor(Color.WHITE);
paintText.setTextSize(20);
counter = 1;
second = (int )(System.currentTimeMillis()/1000);
lastFPS = 0;
}
public void tick(Canvas $canvas){
int $second = (int )(System.currentTimeMillis()/1000);
if ($second == second) counter++;
else {
lastFPS = counter;
counter = 1;
second = $second;
}
render($canvas);
}
public void render(Canvas $canvas){
$canvas.drawRect(drawRect, paint);
$canvas.drawText("FPS:" + lastFPS, drawRect.left + 8, drawRect.bottom/2 + 5, paintText);
}
}
Java Source Code List com.gamepatriot.androidframework.framework.AndroidAnimationData.java com.gamepatriot.androidframework.framework.AndroidAtlas.java com.gamepatriot.androidframework.framework.AndroidBasicShape.java com.gamepatriot.androidframework.framework.AndroidGameData.java com.gamepatriot.androidframework.framework.AndroidImage.java com.gamepatriot.androidframework.framework.AndroidInputter.java com.gamepatriot.androidframework.framework.AndroidMain.java com.gamepatriot.androidframework.framework.AndroidMusicHandler.java com.gamepatriot.androidframework.framework.AndroidPool.java com.gamepatriot.androidframework.framework.AndroidRenderer.java com.gamepatriot.androidframework.framework.AndroidScreen.java com.gamepatriot.androidframework.framework.AndroidShape.java com.gamepatriot.androidframework.framework.AndroidSoundHandler.java com.gamepatriot.framework2d.classes.FPS.java com.gamepatriot.framework2d.implementation.AnimationData.java com.gamepatriot.framework2d.implementation.Atlas.java com.gamepatriot.framework2d.implementation.BasicShape.java com.gamepatriot.framework2d.implementation.GameData.java com.gamepatriot.framework2d.implementation.Image.java com.gamepatriot.framework2d.implementation.Inputter.java com.gamepatriot.framework2d.implementation.Main.java com.gamepatriot.framework2d.implementation.MusicHandler.java com.gamepatriot.framework2d.implementation.Pool.java com.gamepatriot.framework2d.implementation.Renderer.java com.gamepatriot.framework2d.implementation.Screen.java com.gamepatriot.framework2d.implementation.Shape.java com.gamepatriot.framework2d.implementation.SoundHandler.java com.gamepatriot.framework2d.screens.Example.java