如何摔倒另一个使用Android的一个雪碧和引擎? [英] How to fall a sprite over another using And engine in android?

查看:116
本文介绍了如何摔倒另一个使用Android的一个雪碧和引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我怎么可以把一个精灵在另一个精灵如下所示的图像中

你可以看到有是二精灵的形象(1)在顶.The精灵应该把在底部精灵作为图所示(3)。我尝试了一些和发动机的例子,但没有得到任何解决方案还没有。如果任何一个知道如何处理这个问题,请提前发现一些解决或任何source.Thanks

附加code按编辑

 公共类MainActivity扩展SimpleBaseGameActivity {
// ================================================ ===========
//常量
// ================================================ ===========私有静态最终诠释CAMERA_WIDTH = 720;
私有静态最终诠释CAMERA_HEIGHT = 480;
私有静态最终诠释LAYER_COUNT = 4;
 一幕一幕;
// ================================================ ===========
//领域
// ================================================ ===========私人相机mCamera;私人字体mFont;私人BitmapTextureAtlas mBitmapTextureAtlas;
私人ITextureRegion mBadgeTextureRegion;
私人ITextureRegion mNextTextureRegion;私有静态最终IEaseFunction [] [] = EASEFUNCTIONS新IEaseFunction [] [] {
    新IEaseFunction [] {
            EaseLinear.getInstance(),
            EaseLinear.getInstance(),
            EaseLinear.getInstance()
    },};私人INT mCurrentEaseFunctionSet = 0;私人最终雪碧[] = mBadges新的Sprite [1];
//私人最终文本[] = mEaseFunctionNameTexts新文本[3];// ================================================ ===========
//构造函数
// ================================================ ===========// ================================================ ===========
//吸气和放大器;二传手
// ================================================ ===========// ================================================ ===========
//方法/从父类/接口
// ================================================ ===========
公共EngineOptions onCreateEngineOptions(){
    this.mCamera =新照相机(0,0,CAMERA_WIDTH,CAMERA_HEIGHT);    返回新EngineOptions(真,ScreenOrientation.LANDSCAPE_FIXED,新RatioResolutionPolicy(CAMERA_WIDTH,CAMERA_HEIGHT),this.mCamera);
}
公共无效onCreateResources(){
    / *字体。 * /
    最终ITexture fontTexture =新BitmapTextureAtlas(this.getTextureManager(),256,256,TextureOptions.BILINEAR);
    this.mFont =新字体(this.getFontManager(),fontTexture,Typeface.create(Typeface.DEFAULT,Typeface.BOLD),32,真实,Color.WHITE);
    this.mFont.load();    / *的纹理。 * /
    this.mBitmapTextureAtlas =新BitmapTextureAtlas(this.getTextureManager(),256,128,TextureOptions.BILINEAR);
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath(GFX /);
    this.mNextTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas,这一点,next.png,0,0);
    this.mBadgeTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas,这一点,.vi推广员,97,0);    this.mBitmapTextureAtlas.load();
}
公共场景onCreateScene(){
    this.mEngine.registerUpdateHandler(新FPSLogger());现场=新场景();    / *创建一个会动的精灵。 * /    this.mBadges [0] =新的Sprite(0,CAMERA_HEIGHT - 300,this.mBadgeTextureRegion,this.getVertexBufferObjectManager());
    scene.attachChild(this.mBadges [0]);    返回现场;
}
公共无效onGameCreated(){    this.reanimate();
    }
// ================================================ ===========
// 方法
// ================================================ ===========
私人无效复活(){
    this.runOnUpdateThread(新的Runnable(){        公共无效的run(){
            最后IEaseFunction [] = currentEaseFunctionsSet EASEFUNCTIONS [MainActivity.this.mCurrentEaseFunctionSet]
        //最后的文本[] = easeFunctionNameTexts MainActivity.this.mEaseFunctionNameTexts;
            最后雪碧[] =面孔MainActivity.this.mBadges;
            // easeFunctionNameTexts [I] .setText(currentEaseFunctionsSet [I] .getClass()getSimpleName());
                最后雪碧FACE =面孔[0];                face.clearEntityModifiers();                最终浮动Y = face.getY();
                face.setPosition(0,y)基
                face.registerEntityModifier(新MoveModifier(3,0,CAMERA_WIDTH - face.getWidth(),Y,Y,currentEaseFunctionsSet [0]));        }
    });
}// ================================================ ===========
//内部和匿名类
// ================================================ ===========
}


解决方案

只需添加这code!

  this.mBadges [1] =新的雪碧(0,CAMERA_HEIGHT  -  300,this.mBadgeTextureRegion,this.getVertexBufferObjectManager());
scene.attachChild(this.mBadges [1]);
this.mBadges [1] .setPosition(位X,mBadges [0] .getY() - mBadges [1] .getHeight());

无论你是位X通过取代它。

Hi how can i put a one sprite over another sprite as seen in the image below

as you can seen there is two sprite in the image (1).The sprite in the top should place over the sprite in the bottom as seen in the image (3).I tried some And engine example but did not get any solution yet .If any one know how to handle this problem please find some solution or any source.Thanks in advance

Attaching code as per the edit

public class MainActivity extends SimpleBaseGameActivity {
// ===========================================================
// Constants
// ===========================================================

private static final int CAMERA_WIDTH = 720;
private static final int CAMERA_HEIGHT = 480;
private static final int LAYER_COUNT = 4;
 Scene scene;
// ===========================================================
// Fields
// ===========================================================

private Camera mCamera;

private Font mFont;

private BitmapTextureAtlas mBitmapTextureAtlas;
private ITextureRegion mBadgeTextureRegion;
private ITextureRegion mNextTextureRegion;

private static final IEaseFunction[][] EASEFUNCTIONS = new IEaseFunction[][]{
    new IEaseFunction[] {
            EaseLinear.getInstance(),
            EaseLinear.getInstance(),
            EaseLinear.getInstance()
    },

};

private int mCurrentEaseFunctionSet = 0;

private final Sprite[] mBadges = new Sprite[1];
//private final Text[] mEaseFunctionNameTexts = new Text[3];

// ===========================================================
// Constructors
// ===========================================================

// ===========================================================
// Getter & Setter
// ===========================================================

// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================


public EngineOptions onCreateEngineOptions() {
    this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);

    return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera);
}


public void onCreateResources() {
    /* The font. */
    final ITexture fontTexture = new BitmapTextureAtlas(this.getTextureManager(), 256, 256, TextureOptions.BILINEAR);
    this.mFont = new Font(this.getFontManager(), fontTexture, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32, true, Color.WHITE);
    this.mFont.load();

    /* The textures. */
    this.mBitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 256, 128, TextureOptions.BILINEAR);
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
    this.mNextTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, "next.png", 0, 0);
    this.mBadgeTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, "badge.png", 97, 0);

    this.mBitmapTextureAtlas.load();
}


public Scene onCreateScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

scene = new Scene();



    /* Create the sprites that will be moving. */

    this.mBadges[0] = new Sprite(0, CAMERA_HEIGHT - 300, this.mBadgeTextureRegion, this.getVertexBufferObjectManager());


    scene.attachChild(this.mBadges[0]);

    return scene;
}


public void onGameCreated() {

    this.reanimate();
    }








// ===========================================================
// Methods
// ===========================================================


private void reanimate() {
    this.runOnUpdateThread(new Runnable() {

        public void run() {
            final IEaseFunction[] currentEaseFunctionsSet = EASEFUNCTIONS[MainActivity.this.mCurrentEaseFunctionSet];
        //  final Text[] easeFunctionNameTexts = MainActivity.this.mEaseFunctionNameTexts;
            final Sprite[] faces = MainActivity.this.mBadges;


            //  easeFunctionNameTexts[i].setText(currentEaseFunctionsSet[i].getClass().getSimpleName());
                final Sprite face = faces[0];

                face.clearEntityModifiers();

                final float y = face.getY();
                face.setPosition(0, y);
                face.registerEntityModifier(new MoveModifier(3, 0, CAMERA_WIDTH - face.getWidth(), y, y, currentEaseFunctionsSet[0]));

        }
    });
}

// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}

解决方案

Just add this code!

this.mBadges[1] = new Sprite(0, CAMERA_HEIGHT - 300, this.mBadgeTextureRegion, this.getVertexBufferObjectManager());


scene.attachChild(this.mBadges[1]);
this.mBadges[1].setPosition(positionX, mBadges[0].getY()-mBadges[1].getHeight());

Whatever your positionX is replace it by that.

这篇关于如何摔倒另一个使用Android的一个雪碧和引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆