Sie sind auf Seite 1von 5

final AnimatedSprite enemyHelicopter = new AnimatedSprite(

x,
y,
resource
sManager.enemyHelicopterTextureRegion,
vbom);
// granice kretanja heli
koptera
final float maxX;
final float minX;
/*
* Ako je na desnoj stra
ni ekrana ide animacija za
* desnu stranu i postav
lja se da avion ulece u sredinu na pocetku
*/
if (x > sideBorderX) {//
desno
enemyHelicopter.
animate(animationOf2Sprites, 2,
3, true);
maxX=x;
minX=x-200;
} else {//lijevo
enemyHelicopter.
animate(animationOf2Sprites, 0,
1, true);
maxX=x+200;
minX=x;
}
levelObject = enemyHelic
opter;
final Body body = Physic
sFactory.createBoxBody(
gamePhys
icsWorld, levelObject,
BodyType
.KinematicBody, FIXTURE_DEF);
// da ulijece ka sredini
if (x > sideBorderX) {
body.setLinearVelocity(
v2HelicopterFromRightToLeftSide);
} else {
body.setLinearVelocity(v
2HelicopterFromLeftToRightSide);
}
// TODO kontakt listener
za enemy helicopter
body.setUserData("enemyH
elicopter");
gamePhysicsWorld
.registe
rPhysicsConnector(new PhysicsConnector(
levelObject, body, true, false) {
@Override
public void onUpdate(
float pSecondsElapsed) {
super.onUpdate(pSecondsElapsed);
if (player.getY() < levelObject
.getY() + 600) {
if (levelObject.getX() <= minX) {
body.setLinearVelocity(v2HelicopterFromLeftToRightSide);
((AnimatedSprite) levelObject)
.animate(
animationOf2Sprites,
0, 1, true);
}
if (levelObject.getX() >= maxX) {
body.setLinearVelocity(v2HelicopterFromRightToLeftSide);
((AnimatedSprite) levelObject)
.animate(
animationOf2Sprites,
2, 3, true);
}
}
// brisanje iz radne memorije kad
// igrac prodje helikopter
if (player.getY() < levelObject
.getY() - 100) {
levelObject
.setIgnoreUpdate(true);
body.setActive(false);
}
}
});
// fitnes program link
http://blog.shareitfitness.com/2012/intense-at-home-fat-burning-cardio-workout-
no-equipment-required/
{
@Override
public void onUpdate(
float pSecondsElapsed) {
super.onUpdate(pSecondsElapsed);
// Reusing object
if ((player.getY() < levelObject
.getY() - 100)
&& (levelObject.getY()
- cloudAndBoltMovement > bottomBorder)) {
levelObject
.setPosition(
getNextCloudAndBoltX(),
levelObject
.getY()
- cloudAndBoltMovement);
}
/*
* ignorisanje update-a ukoliko
* igrac prodje donju granicu do
* koje se smiju oblaci nalaziti
*/
if (player.getY() < bottomBorder) {
levelObject
.setIgnoreUpdate(true);
}
}
});
// ============================================
// VERTEX HELPER
// ============================================
// your code
public Body createHexBody(final PhysicsWorld pPhysicsWorld, Entity iEnti
ty,
final BodyType pBodyType, final FixtureDef pFixtureDef)
{
final float width = iEntity.getWidth() / pixelToMeter;
final float height = iEntity.getHeight() / pixelToMeter;
final Vector2[] vertices = {
// autogenerated code
new Vector2(+0.00000f*width, -0.09302f*height),
new Vector2(+0.14035f*width, -0.09302f*height),
new Vector2(+0.20175f*width, +0.08140f*height),
new Vector2(-0.13158f*width, +0.61628f*height),
// your code again
};
playerBody = PhysicsFactory.createPolygonBody(pPhysicsWorld, iEn
tity,
vertices, pBodyType, pFixtureDef);
return playerBody;
}
// ============================================
// Upotreba VERTEX HELPER-a
// ============================================
createHexBody(physicsWorld, this, BodyType.DynamicBody,
PhysicsFactory.createFixtureDef(1f, 0, 0));
//==================================================
REUSING OBJECTS QUICK IMPLEMENTATION
//===================================================
@Override
protected void o
nManagedUpdate(
float pSecondsElapsed) {
super.on
ManagedUpdate(pSecondsElapsed);
// Reusi
ng object
if ((pla
yer.getY() < this.getY() - 100)
&& (this.getY() - frekventnost[4] > bottomBorder)) {
this.setPosition(
setReusedObjectX(this.getWidth(),0),
this.getY() - frekventnost[4]);
}
if (play
er.getY() < bottomBorder) {
this.setIgnoreUpdate(true);
}
if (play
er.collidesWith(this)) {
fourLeafCollected = true;
fourLeafY = y;
this.setPosition(
setReusedObjectX(this.getWidth(),0),
this.getY() - frekventnost[4]);
}
}
// ready for cop
y
this.setPosition
(
setReusedObjectX(this.getWidth(),0),
this.getY() - frekventnost[3]);
frekventnost[3]
// todo namjestiti four leaf novcice i four leaf dijamante

Verwandte Interessen