andengine

Use different sprites texture in one generic pool AndEngine

最后都变了- 提交于 2019-12-04 19:26:46
I want to use at least 9 image & they will be use via pool. But i can use only one texture for a Pool Class & can't use rest other. My code: Like: public class BubblePool extends GenericPool<Bubble> { public static BubblePool instance; private PixelPerfectTiledTextureRegion aITiledTextureRegion; public BubblePool(PixelPerfectTiledTextureRegion aTextureRegion) { if (aTextureRegion == null) { throw new IllegalArgumentException( "The Texture Region must not be null"); } this.aITiledTextureRegion = aTextureRegion.deepCopy(); instance = this; } public static BubblePool sharedBubblePool() { // if

Android accelerometer difficulties

陌路散爱 提交于 2019-12-04 19:12:45
I'm a beginner in Android game Development, and I developing a small Game. I am facing some difficulties with the Motion Sensor: Accelerometer. this game is in Landscape mode. I want if my phone tilts in right, my character also goes right. ( same thing for left ) And when I stop tilting Character in the game should stop moving. But i don't understand really good the operation of the accelerometer, here is my code: @Override public void onSensorChanged(SensorEvent event) { synchronized (this) { long penchement = (long) (event.values[1]- 0.5); if(penchement>0){ if(penchement>lastUpdate)

how to move body of sprite using andEngine?

久未见 提交于 2019-12-04 15:01:55
I want to move body of the sprite along with line in some portion of line, just i able to move sprite only but body is not moving. public Scene onLoadScene() { this.mEngine.registerUpdateHandler(new FPSLogger()); final Scene scene = new Scene(2); scene.setBackground(new ColorBackground(0.09804f, 0.00274f, 0.0784f)); this .enableAccelerometerSensor(this ); this.sPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false); final Shape ground = new Rectangle(0, CAMERA_HEIGHT - 2, CAMERA_WIDTH,2); final Shape roof = new Rectangle(0, 0, CAMERA_WIDTH, 2); final Shape left =

Save game state after pause. AndEngine

五迷三道 提交于 2019-12-04 13:32:50
问题 i've found that after resuming the game all the engine is reloaded and application is reinitialized. I want to save engine state and in "onResume" resume the game proccess. I've tried to save all the engine (mEngine) and then after resume the game in "onLoadEngine" return saved engine. I think it is a bad solution and it doesn't work What is the best solution for Pause\Resume the game (after power key pressed for example) in andEngine ? 回答1: The solution I found was to serialize the state of

AndEngine Sprite/Box2D Body removal crashes my program with no error/exception information?

心不动则不痛 提交于 2019-12-04 10:15:08
I am making a skateboarding game with obstacles you have to jump over using box2D and AndEngine. I am trying to make it so that when the player collides with an object, the object is removed and an explosion is placed at the objects old position, however something in the sprite removal code is freezing my program causing it to end (not even a force close message it just closes itself and goes to my home screen) and no error/exception information appears in logcat so I have no idea what is causing it! Here are some code snippets- when I create the sprites/boundaries I attach a JSONObject to the

how to move sprite object using AndEngine (Android)

旧时模样 提交于 2019-12-04 10:11:28
I am using andengine to develop a game in android. I placed an object in sprite like this.mTexture = new Texture(32, 32, TextureOptions.BILINEAR_PREMULTIPLYALPHA); this.mFaceTextureRegion = TextureRegionFactory.createFromAsset(this.mTexture, this, "gfx/bike.png", 0, 0); ---- and i place like Sprite bikeSprite= new Sprite(20, 50, this.mFaceTextureRegion); I want to use this sprite in j2me sprite bikeSprite.move(--); How do I do it in android. I dont want to use setPosition . AZ_ public class EntityModifierExample extends BaseExample { // =========================================================

SharedPreference Changes not reflected in my wallpaper service

家住魔仙堡 提交于 2019-12-04 07:37:02
I am making a live wallpaper where i need to change the speed of a vehicle in setting scene and it needs to get reflected back to the wallpaper service when i press the return button. In my preference activity, i save the list preference changes in shared preferences like this :- @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.prefs); ListPreference listPreference = (ListPreference) findPreference("listPref"); currValue = listPreference.getValue(); Log.e("LiveWallpaperSettings", "currvalue " + currValue);

Screen Capture in andengine gives upside down mirror image

家住魔仙堡 提交于 2019-12-04 07:36:04
In my situation i haven't use RenderSurfaceView. I want to take a screen capture of my scene. But when i save the screen shot it shows upside down mirror image. Cant understand what im doing wrong here. Here is my code attachChild(screenCapture); share_clicked = 1; final int viewWidth = (int)camera.getWidth(); final int viewHeight = (int)camera.getHeight(); Log.d("camera width", "View width :" + viewWidth); Log.d("camera height", "View height :" + viewHeight); File direct = new File( Environment.getExternalStorageDirectory() + "/Word"); if (!direct.exists()) { if (direct.mkdir()) ; //

No EGLConfig found

与世无争的帅哥 提交于 2019-12-04 05:25:00
I'm trying to make simple Game in android using AndEngine tutorial Now When I run the project I get the error saying that java.lang.IllegalArgumentException: No EGLConfig found! TowerOfHanoiActivity.java public class TowerOfHanoiActivity extends SimpleBaseGameActivity { private static int CAMERA_WIDTH = 800; private static int CAMERA_HEIGHT = 480; private ITextureRegion mBackgroundTextureRegion, mTowerTextureRegion, mRing1, mRing2, mRing3; @Override public EngineOptions onCreateEngineOptions() { final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); return new EngineOptions(true,

How do I make a body ignore gravity (AndEngine)?

强颜欢笑 提交于 2019-12-04 04:33:51
问题 I have a sprite (with a body) that bounces around the scene. It needs to be unaffected by gravity, but also able to collide with other bodies on the scene. This means I cannot use a kinematic body. I tried: body = PhysicsFactory.createCircleBody(mPhysicsWorld, this, BodyType.DynamicBody, PhysicsFactory.createFixtureDef(.5f, .5f, .5f)); MassData md = new MassData(); md.mass=0; body.setMassData(md); mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(this, body, true, true)); with