Android learning Platform

Android learning Platform This is a Platform where you can learn to develop android mobile application easily. Like | Comment | Share | Education for everyone...

https://www.facebook.com/Xorrex.Education/photos/a.1462025624112798.1073741829.1450038291978198/1538287303153296/?type=3
26/12/2015

https://www.facebook.com/Xorrex.Education/photos/a.1462025624112798.1073741829.1450038291978198/1538287303153296/?type=3

Advance your career in Karachi’s most progressive Android Training and Apps Development platform Xorrex offers training course, designed to provide advanced knowledge and skills to develop applications for android platform.
What we offer:
We support transformative model of learning’
Focus on Native Development
Course endowed at cost-affordable fees
Syllabus comprises of 2 modules

On completion, students will be given course completion certificate
Placement focused training with Interview preparation
Learn under the guidance of highly experienced Android professional..

21/10/2015
16/10/2015
15/10/2015

LevelController class is responsible for loading levels and controlling level events. Arraylists enemyList, goodsList and endPointList are used for storing enemy balls, goods (diamonds) and end points (finish line). Method createPlayer creates a new player on position x,y with size 30x30, PhysicFactory.CreateFixtureDef creates a new physical object. Physical object should be registered to mPhysicsWorld for collision detection.

public void callbackCollisionGoods(int i){
Shape goodShape = goodsList.get(i);
scene.getBottomLayer().removeEntity(goodShape);
goodsList.remove(i);
}
If player collects diamond, callbackCollisionGoods is called. In this method, we remove diamond from goodsList and goodShape from scene.

Other methods in this class are very similar and I won't describe them in detail.

The next class is PlayerProfileManager. In this class, you will find only basic Java code except method WriteSettings.

private void WriteSettings() {
String FILENAME = "settings2";
FileOutputStream fos = null;
DataOutputStream dos;

try {
fos = gameLogicController.openFileOutput(FILENAME, Context.MODE_PRIVATE);
} catch (FileNotFoundException e) {
}
try {
dos=new DataOutputStream(fos);

dos.writeInt(unlockedLevelId);
} catch (IOException e) {
}
try {
fos.close();
} catch (IOException e) {
}
}
In method WriteSettings, we save level information to mobile phone. It's necessary to open, write and close file. Actually, we save only one number - ID of last unlocked level. For example, if level ID is 5, then levels 1, 2, 3, 4 and 5 are unlocked.

The last described class is Player.

public class Player extends AnimatedSprite {..

protected void onManagedUpdate(final float pSecondsElapsed) {
super.onManagedUpdate(pSecondsElapsed);
onBeforePositionChanged();
}

private boolean onBeforePositionChanged(){

//speed up
if(frameCount < 2){
frameCount++;
return true;
}
frameCount = 0;

int enemyListSize = levelController.getEnemyList().size();
for(int i = 0; i < enemyListSize; i++)
if(this.collidesWith(levelController.getEnemyList().get(i)))
{
levelController.callbackCollisionEnemy();
return false;
}
for(int i = 0; i < levelController.getGoodsList().size(); i++)
if(this.collidesWith(levelController.getGoodsList().get(i)))
{
levelController.callbackCollisionGoods(i);
return false;
}

for(int i = 0; i < levelController.getEndPointList().size(); i++)
if(this.collidesWith(levelController.getEndPointList().get(i)))
{
levelController.callbackCollisionWithEndPoint();
return false;
}
return true;
}..
}
Player class is extended AnimatedSprite. The difference between Sprite and AnimatedSprite is just one - animated sprite consists of more pictures (animation) while Sprite consist of one picture. OnManagedUpdate is callback executed every "x" miliseconds. OnBeforePositionChanged checks if player is in collision with enemy, diamond or end point. If it's in collision, then the appropriate callback is executed.

Android Game Developing
I hope you see that Android game developing isn't too hard. With some practice, you can develop your Android dream game. At the end of the tutorial, I would like to thank you for your attention. This is my first article and I would be really glad if you give me any feedback.

15/10/2015

blic class LevelController {
private ArrayList enemyList;
private ArrayList goodsList;
private ArrayList endPointList;
...

public void createPlayer(TiledTextureRegion mCircleFaceTextureRegion, int x, int y){
//mPlayer = new Player(x, y, mCameraHeight/10,mCameraHeight/10,
mCircleFaceTextureRegion, this);
mPlayer = new Player(x, y, 30,30,mCircleFaceTextureRegion, this);
FixtureDef FIXTURE = PhysicsFactory.createFixtureDef(1, 0.5f, 0.5f);
Body body;
body = PhysicsFactory.createCircleBody(mPhysicsWorld, mPlayer,
BodyType.DynamicBody, FIXTURE);

mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector
(mPlayer, body, true, true, false, false));
scene.getTopLayer().addEntity(mPlayer);
}..
}

15/10/2015

public Scene newGameLevelScene(int levelId){
Scene scene = new Scene(2);
this.mPhysicsWorld = new FixedStepPhysicsWorld(60, new Vector2(0, 0), false);
levelController.setScene(scene);
levelController.setmPhysicsWorld(mPhysicsWorld);
levelController.createFrame();
levelController.loadLevel(levelId);
this.enableAccelerometerSensor(this);
scene.registerUpdateHandler(this.mPhysicsWorld);
return scene;
}

15/10/2015


public Engine onLoadEngine() {
...

levelController.mCameraWidth = 460;
levelController.mCameraHeight = 320;
camera = new Camera(0, 0, levelController.mCameraWidth,
levelController.mCameraHeight);
return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE,
new RatioResolutionPolicy(levelController.mCameraWidth,
levelController.mCameraHeight), camera).setNeedsSound(true));
}

15/10/2015

blic class GameLogicController extends BaseGameActivity
implements IAccelerometerListener{
public PlayerProfileManager playerProfileManager;
public LevelController levelController;
private Camera camera;
protected PhysicsWorld mPhysicsWorld;
public Texture mTexture;
public TextureRegion enemyTextureRegion;
private float mGravityX;
private float mGravityY;
private final Vector2 mTempVector = new Vector2();
public TiledTextureRegion mCircleFaceTextureRegion;
private RepeatingSpriteBackground mGrassBackground;
private Sound mGameOverSound;
...
}

15/10/2015

What You Need to Start?
To start developing your own Android games, you need SDK and game engine (it will make your life way easier!). I used Eclipse SDK and game engine called AndEngine. Are you wondering how to setup Eclipse SDK and AndEngine together? Click on the link to see "Getting started with AndEngine" tutorial.

Let's Do Some Coding!
Let's see what is hiding in the code! Please note that I didn't paste the full source code here. I just pasted some snippets. You can download the full project to see the complete source code.

First, we will take a short tour in the main class.

15/10/2015

It's a classic game idea implemented in a modern way. You control the ball using the accelerometer sensor and your goal is to collect all "diamonds", avoid enemy balls and to come safely to the end.

15/10/2015

troduction
This is a tutorial for developing a Ball Game in Android OS. It will introduce you to developing Android games using AndEngine (free Android 2D open source game engine). To understand this tutorial, you will need to have some basic knowledge about AndEngine and programming in Java. If you don't have knowledge about AndEngine, you should check this link. The goal of this tutorial is to teach you how to make your own Android game.

15/10/2015

Hello friends kesa ha ap sub

Address

Karachi

Website

Alerts

Be the first to know and let us send you an email when Android learning Platform posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share