If you think the Android project LucyTheMoocher 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.lucythemoocher.actors;
//fromwww.java2s.comimport com.lucythemoocher.R;
import com.lucythemoocher.controls.AIController;
import com.lucythemoocher.physics.Cinematic;
import com.lucythemoocher.util.Direction;
/**
* Target of the game.
* I.e. Freddy!!!
*/publicclass TargetCharacter extends Actor {
/**
* Constructor.
* Provided controller expresses the behavior of Freddy
* @param controller AI controller
* @param x
* @param y
*/public TargetCharacter(AIController controller, float x, float y) {
super();
getDrawer().initializeAnimation(R.drawable.freddy);
setCinematic(new Cinematic(0.6f));
getCinematic().addBox(x, y, getH(), getW());
controller_ = controller;
controller_.setControllable(this);
int tab[] = {0,1,2,3};
getDrawer().getAnim().setAnimation(tab, 100);
dir_ = Direction.RIGHT;
}
publicvoid update() {
super.update();
if (dir_ == Direction.LEFT) {
moveLeft();
if ( pos_.hasLeftCollision() ) {
dir_ = Direction.RIGHT;
int tab[] = {0,1,2,3};
getDrawer().getAnim().setAnimation(tab, 100);
}
} else {
moveRight();
if ( pos_.hasRightCollision() ) {
dir_ = Direction.LEFT;
int tab[] = {4,5,6,7};
getDrawer().getAnim().setAnimation(tab, 100);
}
}
}
private AIController controller_;
privateint dir_;
}