I've spent a lot of time today researching why my getters are returning null and cant seem to find a clean answer. I am looking to create a clean hierarchy using classes and pass the information from one to the other. I dont know if this is good practice im still new to game development and android studio in general. I would like to be able to pass the variables from the Game.java(which is my activity class) without adding it to my other classes in their constructors. I want to be able to access the getters like it is another class but cant seem to work out how. Full code will be included below: getXDirection and getyDirecion in the Game.java are returning 0 from the player class which implys they haven't been initialised
Game.java
package com.Frenchie.SpaceshipSammy;
import ...
public class Game extends Activity implements SensorEventListener{
private SensorManager senSensorManager;
private Sensor senAccelerometer;
//Directional constants
private static final int DIRECTION_STATIONARY = 0;
private static final int DIRECTION_LEFT = 1;
private static final int DIRECTION_RIGHT= 2;
private static final int DIRECTION_UP = 3;
private static final int DIRECTION_DOWN= 4;
//Direction variables
private int yDirection, xDirection;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Set view to GameView
setContentView(new GameView(this));
//Sensor stuff
senSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
senAccelerometer = senSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
senSensorManager.registerListener(this, senAccelerometer , SensorManager.SENSOR_DELAY_GAME);
}
#Override
public boolean onTouchEvent(MotionEvent motionEvent) {
switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
//Finger down - Move up
yDirection = DIRECTION_UP;
break;
case MotionEvent.ACTION_UP:
//Finger lifted - Move down
yDirection = DIRECTION_DOWN;
break;
}
return true;
}
//Overriding Accelerometer to read data
#Override
public void onSensorChanged(SensorEvent sensorEvent) {
Sensor mySensor = sensorEvent.sensor;
if (mySensor.getType() == Sensor.TYPE_ACCELEROMETER) {
float x = sensorEvent.values[1];
if (x > -1 && x < 1) {
//Stationary
xDirection = DIRECTION_STATIONARY;
} else if (x >= 1) {
//Move right
xDirection = DIRECTION_RIGHT;
} else if (x <= -1) {
//Move left
xDirection = DIRECTION_LEFT;
} else {
Log.d("onSensorChanged", "Escaped");
}
}
}
#Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
//Getters for Player class to use
public int getyDirection() {
return yDirection;
}
public int getxDirection() {
return xDirection;
}
}
Player.java
package com.Frenchie.SpaceshipSammy;
import ...
public class Player {
//Directional constants
private static final int DIRECTION_STATIONARY = 0;
private static final int DIRECTION_LEFT = 1;
private static final int DIRECTION_RIGHT = 2;
private static final int DIRECTION_UP = 3;
private static final int DIRECTION_DOWN = 4;
//Location variables
private int x, y, speed;
//Sprite
private Bitmap sprite;
private Game userInput;
public Player(Context context){
speed = 10;
userInput = new Game();
sprite = BitmapFactory.decodeResource(context.getResources(), R.drawable.player);
}
//Called from Logic to move players location
public void PositionUpdate(){
xMove();
yMove();
}
private void xMove(){
if (userInput.getxDirection() == DIRECTION_STATIONARY){
//Stationary
}
else if (userInput.getxDirection() == DIRECTION_RIGHT){
//Move right
x += speed;
Log.d("xMove","Right");
}
else if (userInput.getxDirection() == DIRECTION_LEFT){
//Move left
x -= speed;
}
else {
Log.d("xMove", "xDirection unrecognised");
}
}
private void yMove(){
if (userInput.getyDirection() == DIRECTION_UP){
//Move up
y -= speed;
}
else if (userInput.getyDirection() == DIRECTION_DOWN){
//Move down
y += speed;
}
else{
//Log.d("yMove", "yDirection unrecognised");
}
}
//Get x and y for Logic
public int getX() {
return x;
}
public int getY() {
return y;
}
public Bitmap getSprite() {
return sprite;
}
}
Logic.java
package com.Frenchie.SpaceshipSammy;
import ...
public class Logic implements Runnable {
//Bring in required classes
private Player player;
//Player variables
private int yPlayer, xPlayer;
private Bitmap playerSprite;
public Logic(Context context){
player = new Player(context);
//Sprite currently wont change so this doesn't need to be updated with the location
playerSprite = player.getSprite();
//Creating and running thread
Thread thread = new Thread(this);
thread.start();
}
//Thread to tell the players position update method to run and update the players values in this class
#Override
public void run() {
while(true) {
player.PositionUpdate();
PlayerLocation();
}
}
//Updates the players location which can be passed onto GameView
public void PlayerLocation(){
xPlayer = player.getX();
yPlayer = player.getY();
}
//Getters for GameView to use
public int getyPlayer() {
return yPlayer;
}
public int getxPlayer() {
return xPlayer;
}
public Bitmap getPlayerSprite() {
return playerSprite;
}
}
GameView.java
package com.Frenchie.SpaceshipSammy;
import ...
public class GameView extends SurfaceView implements Runnable{
private SurfaceHolder surfaceHolder = getHolder();
private Canvas canvas;
//Link Logic class
private Logic logic;
public GameView(Context context) {
super(context);
//Creates logic as a new object
logic = new Logic(context);
//Creates and starts the thread
Thread thread = new Thread(this);
thread.start();
}
//Override thread method. This is called when the thread is started
#Override
public void run() {
while (true){
DrawFrame();
}
}
private void DrawFrame(){
canvas = surfaceHolder.lockCanvas();
if (surfaceHolder.getSurface().isValid()){
canvas.drawColor(Color.MAGENTA);
canvas.drawBitmap(logic.getPlayerSprite(), logic.getxPlayer(), logic.getyPlayer(), null);
surfaceHolder.unlockCanvasAndPost(canvas);
} else {
Log.d("DrawFrame", "Surface Invalid");
}
}
}
All help is appreciated!
This is your problem, in your GameView
userInput = new Game();
You are pointing to a new instance of your Activity, not the actual Activity that is displayed. You need to set this value after the Player is created with the activity instance 'this'.
Related
I'm trying to access the same instance of a class from multiple classes.
I have a class for my turret and I'm trying to draw the turret using my View class and, at the same time, update its location using my logic class. I don't understand how to check if the class already has a running instance and if it does how to access the running instance. I can't find anything online I understand and it's going right over my head, all help is appreciated!
Turrets
public class Turrets {
int health, x, y, speed;
Bitmap sprite;
public Turrets (Context context){ }
public void isMoving(){
x += speed;
}
public int getHealth() {return health;}
public int getX() {return x;}
public int getY() {return y;}
public Bitmap getSprite() {return sprite;}
}
SimpleTurret
public class SimpleTurret extends Turrets {
public SimpleTurret(Context context){
super(context);
sprite = BitmapFactory.decodeResource(context.getResources(), R.drawable.test_sprite);
health = 50;
x = 300;
y = 100;
speed = 1;
}
}
Logic
public class Logic implements Runnable{
Boolean isRunning;
private Thread logicThread;
SimpleTurret simpleTurret;
public Logic(Context context, boolean running){
simpleTurret = new SimpleTurret(context);
logicThread = new Thread(this);
logicThread.start();
isRunning = running;
}
#Override
public void run() {
while (isRunning){
gameView.rapidFireTurret.isMoving();
}
}
}
GameView
public class GameView extends SurfaceView implements Runnable {
private boolean running = true;
SurfaceHolder surfaceHolder = getHolder();
SimpleTurret simpleTurret;
RapidFireTurret rapidFireTurret;
public GameView (Context context){
super(context);
Thread thread = new Thread(this);
thread.start();
}
#Override
public void run() {
while (running){
DrawCanvas();
}
}
public void DrawCanvas(){
Canvas canvas = surfaceHolder.lockCanvas();
if (surfaceHolder.getSurface().isValid()){
canvas.drawColor(Color.RED);
canvas.drawBitmap(simpleTurret.getSprite(), simpleTurret.getX(), simpleTurret.getY(), null);
surfaceHolder.unlockCanvasAndPost(canvas);
}
}
}
Use Singleton like class.
// Java program implementing Singleton class
// with getInstance() method
class Singleton {
// static variable single_instance of type Singleton
private static Singleton single_instance_first = null;
private static Singleton single_instance_second = null;
private static Singleton single_instance_third = null;
// variable of type String
public String s;
// private constructor restricted to this class itself
private Singleton() {
s = "Hello I am a string part of Singleton class";
}
// static method to create instance of Singleton class
public static Singleton getInstance(int index) {
switch (index) {
case 0: {
if (single_instance_first == null)
single_instance_first = new Singleton();
return single_instance_first;
}
case 1: {
if (single_instance_second == null)
single_instance_second = new Singleton();
return single_instance_second;
}
case 2: {
if (single_instance_third == null)
single_instance_third = new Singleton();
return single_instance_third;
}
default: {
if (single_instance_first == null)
single_instance_first = new Singleton();
return single_instance_first;
}
}
}
}
and use
Singleton firstSingleton = Singleton.getInstance(0);
Singleton secondSingleton = Singleton.getInstance(1);
Singleton thirdSingleton = Singleton.getInstance(2);
Change your class to this
public class Turrets {
int health, x, y, speed;
Bitmap sprite;
static Singleton mInstance;
Context mContext;
public Turrets (Context context){
this.mContext=context;
}
public void isMoving(){
x += speed;
}
public int getHealth() {return health;}
public int getX() {return x;}
public int getY() {return y;}
public Bitmap getSprite() {return sprite;}
public static Turrets getInstance()
{
if (mInstance == null) {
mInstance = new Turrets(mContext);
}else {
return mInstance;
}
}
}
I'm new to java and i was searching about this for a long time. How can I have access to the item's b variables in class Player??(the cod i'm posting is a part of my full programm so don't mind if you see methods or variables that are not declared in the following code)
import java.util.Random;
public abstract class Player {
private int x, y;
private String name;
private int pNumber;
private int mLine;
private int tLine;
private boolean possession;
private int c;
private int f = 0;
private int i = 0;
public int getPlx() {
return x;
}
public void setPlx(int x) {
this.x = x;
}
public int getPly() {
return y;
}
public void setPly(int y) {
this.y = y;
}
public String getPName() {
return name;
}
public void setPName(String name) {
this.name = name;
}
public int getPNum() {
return pNumber;
}
public void setPNum(int pNumber) {
this.pNumber = pNumber;
}
public int getMLine() {
return mLine;
}
public void setMLine(int mLine) {
this.mLine = mLine;
}
public int getLine() {
return tLine;
}
public void setTLine(int tLine) {
this.tLine = tLine;
}
public boolean getPos() {
return possession;
}
public void setPos(boolean possession) {
this.possession = possession;
}
private Random rand = new Random();
public void Move() { //me8odos metakinisis
c = rand.nextInt(2);
if (c == 0) {
y++;
} else {
y--;
}
}
public void Pass() {
if (this.possession == true) {
c = rand.nextInt(10);
while ((f == 0) && (i < 10)) {
if (main.barcelona.get(i).name == this.name) {}
}
}
}
public abstract void SpecialMove();
}
public class Ball {
private int x, y;
private Player formerP = null;
private Player currentP = null;
public Ball(int x, int y, Player formerP, Player currentP) {
this.x = x;
this.y = y;
this.formerP = formerP;
this.currentP = currentP;
}
public int getBX() {
return x;
}
public void setBX(int x) {
this.x = x;
}
public int getBY() {
return y;
}
public void setBY(int y) {
this.y = y;
}
void Assign(Player playerP) {
int px = playerP.getPlx();
if (this.currentP == null) {
if (((this.x - px <= 1) || (px - this.x) <= 1)
&& ((this.x - px <= 1) || (px - this.x) = 1)) {
this.currentP = playerP;
this.formerP.possession = false;
playerP.possession = true;
if (this.currentP.team == this.formerP.team) {
int pass = this.currentP.getPasses();
pass++;
this.currentP.setPasses(pass);
} else {
int mistake = this.currentP.getMistakes();
mistake++;
this.currentP.setMistakes(mistake);
}
}
}
this.formerP = this.currentP;
this.currentP = null;
this.formerP = null;
}
}
try BallClassName.getX();
You may have to make getX static
If you don't want to instantiate the class Ball in the Player class and you would like to ensure that all players are playing with the one and only ball, then consider making Ball a Singleton.
In software engineering, the singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.
public class Ball {
private static Ball singletonBall;
private int x;
private int y;
private Player formerP;
private Player currentP;
public static Ball getSingletonBall() {
if(singletonBall == null){
singletonBall = new Ball();
}
return singletonBall;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public Player getFormerP() {
return formerP;
}
public void setFormerP(Player formerP) {
this.formerP = formerP;
}
public Player getCurrentP() {
return currentP;
}
public void setCurrentP(Player currentP) {
this.currentP = currentP;
}
}
If there is something that you need inside Player that you will be using often that won't change throughout the life of the Player object (or sub object in your case), then you might as well pass it to a local variable through the Player constructor.
Let's assume Item B is the Ball and you have a Ball class.
So in player (or sub player) declare your object you want access to:
class Player {
Ball ball;
public Player(Ball ball) {
this.ball = ball;
}
Or if it's just something that you'll be using infrequently or something that's value will change (more likely with a ball), then create a method to perform what you need on the Player object.
class Player {
.
.
.
.
.
public void dribble(Ball ball) {
// do something with the ball
ball.setPosition(10, 20);
ball.update();
}
}
Then whatever instantiates Player can access that method.
public static void main(String[] args) {
Player player = new Player();
Ball ball = new Ball();
player.dribble(ball);
}
I know similar questions have been asked before but none of those solutions worked for me.
I'm trying to create a small 2D game for Android and I am having some problems using SurfaceView.
My main activity currently looks like this:
public class MainActivity extends Activity {
private static final String TAG = "MainActivity";
private DrawingSurface drawingsurface;
private Game game;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate()");
setFullscreen();
game = new Game();
drawingsurface = new DrawingSurface(this, game);
setContentView(drawingsurface);
}
private void setFullscreen() {
// ...
}
}
As you can see, I set my activity to fullscreen, create a new SurfaceView (called drawingSurface) and create a new game instance.
My SurfaceView (called DrawingSurface) looks like this:
public class DrawingSurface extends SurfaceView implements SurfaceHolder.Callback {
private GameThread thread;
private static final String TAG = "DrawingSurface";
public DrawingSurface(Context context, Game game) {
super(context);
getHolder().addCallback(this);
setFocusable(true);
// create a new game rendering thread and pass it game so it can call the update() and render() functions of game:
thread = new GameThread(getHolder(), this, game);
}
#Override
public void surfaceCreated(SurfaceHolder holder) {
Log.v(TAG, "surfaceCreated()");
// start the rendering thread:
thread.setRunning(true);
thread.start();
}
#Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Log.v(TAG, "surfaceChanged()");
// do I need to do anything in here?
}
#Override
public void surfaceDestroyed(SurfaceHolder holder) {
// stop the rendering thread:
Log.v(TAG, "surfaceDestroyed()");
thread.setRunning(false);
boolean retry = true;
while (retry) {
try {
thread.join();
} catch (InterruptedException e) {
// try again shutting down the thread
}
}
}
#Override
public boolean onTouchEvent(MotionEvent event) {
// pass the touch event to the Game instance (to keep everything in on place)
thread.game.onTouchEvent(event);
return super.onTouchEvent(event);
}
#Override
protected void onDraw(Canvas canvas) {
// I don't use onDraw(), instead I have my own update() and render() functions in my game thread
super.onDraw(canvas);
}
}
This is my game thread:
public class GameThread extends Thread {
private boolean running;
private SurfaceHolder surfaceHolder;
private DrawingSurface drawingSurface;
private static final String TAG = GameThread.class.getSimpleName();
protected Game game;
public GameThread(SurfaceHolder surfaceHolder, DrawingSurface drawingSurface, Game game) {
super();
this.surfaceHolder = surfaceHolder;
this.drawingSurface = drawingSurface;
this.game = game;
}
public void setRunning(boolean running) {
this.running = running;
}
#SuppressLint("WrongCall")
#Override
public void run() {
Log.d(TAG, "Starting game loop");
long now;
long dt;
long last = System.currentTimeMillis();
Canvas canvas;
while (running) {
Log.v(TAG, "GameThread running");
canvas = null;
/* try locking the canvas for exclusive
pixel editing in the surface */
try {
canvas = this.surfaceHolder.lockCanvas();
synchronized (this.surfaceHolder) {
now = System.currentTimeMillis();
dt = (now - last);
this.game.update(dt);
if(canvas != null)
this.game.render(canvas, dt);
last = now;
}
} finally {
/*in case of an exception the surface
is not left in an inconsistent state */
if (canvas != null) {
this.surfaceHolder.unlockCanvasAndPost(canvas);
}
}
if (dt < 16) {
try {
Thread.sleep(16 - dt);
} catch (InterruptedException e) {
}
}
}
}
}
And this is the Game class:
public class Game {
private static final String TAG = "Game";
private static int playerRefPosX = 40;
private int playerY = 0;
private int playerVelY = 1;
public Game() {
Log.v(TAG, "Game instance created");
}
public void update(long dt) {
playerY += playerVelY * dt;
if (playerY > 1800) {
playerVelY = -playerVelY;
}
if (playerY < 0) {
playerVelY = -playerVelY;
}
}
public void render(Canvas canvas, long dt) {
canvas.drawColor(Color.BLACK);
// draw Player
Paint paint = new Paint();
paint.setTextSize(100);
paint.setColor(new Color().rgb(255, 0, 0));
canvas.drawRect(playerRefPosX, playerY + 100, playerRefPosX + 200, playerY - 100, paint);
canvas.drawText(String.valueOf(1000/dt), canvas.getWidth()/2, canvas.getWidth()/2, paint);
}
public void onTouchEvent(MotionEvent event) {
Log.v(TAG, "received touch event..");
}
}
The problems I am have right now:
When I press the home button and reenter the app OR rotate my device it calls surfaceDestroyed() but doesn't recreate it afterwards (the canvas doesn't get repainted)
The game rendering thread never stops (as indicated by the log messages)
I am developing an Android airplane shooter game and I need to get the X and Y position each time the player moves his airplane in order to detect collision.
the class below handles the movement of the player's airplane
package com.pe44.dukes;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
public class DukesGame extends Activity {
final DukesEngine gameEngine = new DukesEngine();
private DukesGameView gameView;
public static float playerPosX, playerPosY;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gameView = new DukesGameView(this);
setContentView(gameView);
}
#Override
protected void onResume() {
super.onResume();
gameView.onResume();
}
#Override
protected void onPause() {
super.onPause();
gameView.onPause();
}
#Override
public boolean onTouchEvent(MotionEvent event) {
//
playerPosX = event.getX();
playerPosY = event.getY();
String SPposX = Float.toString(playerPosX);
String SPposY = Float.toString(playerPosY);
Log.i(SPposX, SPposY);
int height = DukesEngine.display.getHeight() / 4;
int playableArea = DukesEngine.display.getHeight() - height;
if (playerPosY > playableArea){
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
if(playerPosX < DukesEngine.display.getWidth() / 2){
DukesEngine.playerFlightAction = DukesEngine.player_turn_left;
}else{
DukesEngine.playerFlightAction = DukesEngine.player_turn_right;
}
break;
case MotionEvent.ACTION_UP:
DukesEngine.playerFlightAction = DukesEngine.PLAYER_RELEASE;
break;
}
}
return false;
}
public static float getPlayerX(){
return playerPosX;
}
public static float getPlayerY(){
return playerPosY;
}
}
I need to pass the playerPosX = event.getX(); and playerPosY = event.getY(); into my renderer class which is going to handle the collision detection.
I have created two get methods
public static float getPlayerX(){
return playerPosX;
}
public static float getPlayerY(){
return playerPosY;
}
the piece of code which i wrote to handle the collision detection in the renderer class
private void detectCollisionsOnPlayer(){
float playerPosX = DukesGame.getPlayerX();
float playerPosY = DukesGame.getPlayerY();
String posx = Float.toString(playerPosX);
String posy = Float.toString(playerPosX);
Log.d(posx,posy);
for (int d = 0; d < 3; d++){
for (int x = 0; x < DukesEngine.total_fighters + DukesEngine.total_jets + DukesEngine.total_warships - 1; x++ ){
if(enemies[x].posX == playerPosX && enemies[x].posY == playerPosY ){
Log.d("Game Over", "game over");
}
}
}
}
For some reason the X and Y values do not pass into the two methods I created in the DukesGame class. Can anyone suggest a solution for this problem?
I suggest you use an interface instead of setting static values.
How might I draw a graph of a function (for example, y = x^2 or y = (x +1)/(2*x +3)) on a Canvas in an Android app?
Here you have an example code ;D (plots the f(x)=x^3 function)
A sample thread that plots the function.
public class MainThread extends Thread {
private static final String TAG = MainThread.class.getSimpleName();
private SurfaceHolder surfaceHolder;
private MainGamePanel gamePanel;
private Paint paintRed;
private Paint paintBlue;
private boolean running;
public void setRunning(boolean running) {
this.running = running;
}
public MainThread(SurfaceHolder surfaceHolder, MainGamePanel gamePanel) {
super();
this.paintRed = new Paint();
this.paintRed.setColor(Color.RED);
this.paintRed.setStrokeWidth(1);
this.paintBlue = new Paint();
this.paintBlue.setColor(Color.BLUE);
this.paintBlue.setStrokeWidth(1);
this.surfaceHolder = surfaceHolder;
this.gamePanel = gamePanel;
}
class MeasuredAxis {
public static final int X_GAP = 1;
public static final int Y_GAP = 1;
int _realHeight;
int _realWidth;
public MeasuredAxis(int width, int height) {
_realWidth = width;
_realHeight = height;
}
public int getXAxisNegLimit() {
return (_realWidth / 2)*(-1);
}
public int getXAxisLimit() {
return (_realWidth / 2);
}
public float getXMeasured(int x) {
return ((_realWidth / 2) + x);
}
public float getYMeasured(float y) {
return ((_realHeight / 2) - y);
}
}
private float function(float x) {
return new Double(Math.pow(x, 3)).floatValue();
}
#Override
public void run() {
long fps = 0L;
Log.d(TAG, "Starting game loop");
Canvas canvas = surfaceHolder.lockCanvas();
MeasuredAxis measured = new MeasuredAxis(canvas.getWidth(), canvas.getHeight());
synchronized (canvas) {
int x = measured.getXAxisNegLimit();
//from -x to +x evaluate and plot the function
while (x++ < measured.getXAxisLimit()) {
canvas.drawLine(
measured.getXMeasured(x),
measured.getYMeasured(function(x)),
measured.getXMeasured(x+MeasuredAxis.X_GAP),
measured.getYMeasured(function(x+MeasuredAxis.Y_GAP)),
paintRed);
}
canvas.save();
canvas.translate(0, 0);
canvas.scale(canvas.getWidth(), canvas.getHeight());
canvas.restore();
}
surfaceHolder.unlockCanvasAndPost(canvas);
}
}
A sample surface view where the function is drawn.
public class MainGamePanel extends SurfaceView implements
SurfaceHolder.Callback {
private MainThread thread;
public MainGamePanel(Context context) {
super(context);
getHolder().addCallback(this);
// create the game loop thread
thread = new MainThread(getHolder(), this);
setFocusable(true);
}
#Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
#Override
public void surfaceCreated(SurfaceHolder holder) {
thread.setRunning(true);
thread.start();
}
#Override
public void surfaceDestroyed(SurfaceHolder holder) {
boolean retry = true;
while (retry) {
try {
thread.join();
retry = false;
} catch (InterruptedException e) {
// try again shutting down the thread
}
}
}
#Override
public boolean onTouchEvent(MotionEvent event) {
return super.onTouchEvent(event);
}
#Override
protected void onDraw(Canvas canvas) {
}
}
And an example activity
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(new MainGamePanel(this));
}
}
Hope this helps you!