几个月前我已经看了一下dedengine,我设法做了一些事情.现在我下载了最新版本,我最简单的事情就是崩溃了.在这里我的代码
package francesco.mygame;
import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.background.ColorBackground;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.entity.util.FPSLogger;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.anddev.andengine.opengl.texture.region.TextureRegion;
import org.anddev.andengine.ui.activity.BaseGameActivity;
public class mainMenu extends BaseGameActivity
{
// ===========================================================
// Constants
// ===========================================================
static final int CAMERA_WIDTH = 480;
static final int CAMERA_HEIGHT = 320;
//private static final String TAG = "Main Menu";
// ===========================================================
// Fields
// ===========================================================
protected Camera mCamera;
protected BitmapTextureAtlas mTexture;
protected TextureRegion mPlayTexture;
protected Sprite …
Run Code Online (Sandbox Code Playgroud) 我正在开发一款游戏,当游戏正在播放时,音量控制无效.有人能给我解决方案吗?
它在AndEngine中
所以,我正在研究AndEngine PhysicsExample代码.我想知道这种方法的含义是什么(http://pastebin.com/Day2hciB):
private void addFace(final float pX, final float pY) {
this.mFaceCount++;
Debug.d("Faces: " + this.mFaceCount);
final AnimatedSprite face;
final Body body;
if(this.mFaceCount % 4 == 0) {
face = new AnimatedSprite(pX, pY, this.mBoxFaceTextureRegion, this.getVertexBufferObjectManager());
body = PhysicsFactory.createBoxBody(this.mPhysicsWorld, face, BodyType.DynamicBody, FIXTURE_DEF);
} else if (this.mFaceCount % 4 == 1) {
face = new AnimatedSprite(pX, pY, this.mCircleFaceTextureRegion, this.getVertexBufferObjectManager());
body = PhysicsFactory.createCircleBody(this.mPhysicsWorld, face, BodyType.DynamicBody, FIXTURE_DEF);
} else if (this.mFaceCount % 4 == 2) {
face = new AnimatedSprite(pX, pY, this.mTriangleFaceTextureRegion, …
Run Code Online (Sandbox Code Playgroud) 当我必须在我的场景上移动一些精灵(例如,在100px向下)时,我正在使用此代码:
Timer timer = new Timer();
for (int i=0; i<10; i++) {
delay+=frameDelay;
timer.schedule(new TimerTask() {
@Override
public void run() {
sprite.setPosition(sprite.getX(), sprite.getY()+10);
}
},delay);
}
Run Code Online (Sandbox Code Playgroud)
它有效,但我想知道是否有更多正确和/或更快的可能性来做到这一点.
我正在使用AndEngine,我采用了一个组件实体模型来开发我的游戏.我的问题是在AndEngine设置中,我应该在哪里以及如何调用我的实体(及其组件)的更新方法?
我两天前才开始使用AndEngine,所以请原谅我的任何小说.
从场景中删除我的精灵时,我得到一个超出范围的索引.请注意,我想从Explosion类中删除精灵,以使我的游戏类尽可能"干净".
这是我创建精灵的地方.
mScene.registerUpdateHandler(new IUpdateHandler() {
public void onUpdate(float pSecondsElapsed) {
if(something) {
final Explosion expl = new Explosion(m.getX(), m.getY(),
getVertexBufferObjectManager(), false, 65);
mScene.attachChild(expl);
}
}
});
Run Code Online (Sandbox Code Playgroud)
在动画结束时删除精灵的爆炸类
public class Explosion extends AnimatedSprite {
private final Explosion self;
public Explosion(float pX, float pY, VertexBufferObjectManager pVertexBufferObjectManager,
boolean loopAnimation, long frameDurationEach) {
super(pX, pY, regExplosion, pVertexBufferObjectManager);
this.self = this;
this.animate(frameDurationEach, loopAnimation, new IAnimationListener() {
@Override
public void onAnimationStarted(AnimatedSprite pAnimatedSprite,
int pInitialLoopCount) {
}
@Override
public void onAnimationLoopFinished(AnimatedSprite pAnimatedSprite,
int pRemainingLoopCount, int pInitialLoopCount) { …
Run Code Online (Sandbox Code Playgroud) 我开始使用AndEngine,我看到一些教程使用setTouchAreaBindingOnActionDownEnabled
但不解释其目的.
为什么我需要和这个方法一起使用onAreaTouched
?不应该是onAreaTouched
足够的,并检测它里面是否是向下或向上?
谢谢