Search Results

Search found 93 results on 4 pages for 'andengine'.

Page 1/4 | 1 2 3 4  | Next Page >

  • How to build AndEngine in Android Studio?

    - by marcu
    I wanted to build AndEngine and andEnginePhysicsBox2DExtension from Anchor Center branch, but build failed. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':andEngine:compileReleaseNdk'. > com.android.ide.common.internal.LoggedErrorException: Failed to run command: /home/mariusz/android/android-ndk/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/mariusz/Downloads/AndEngineApp/andEngine/build/intermediates/ndk/release/Android.mk APP_PLATFORM=android-17 NDK_OUT=/home/mariusz/Downloads/AndEngineApp/andEngine/build/intermediates/ndk/release/obj NDK_LIBS_OUT=/home/mariusz/Downloads/AndEngineApp/andEngine/build/intermediates/ndk/release/lib APP_ABI=all Error Code: 2 Output: /home/mariusz/android/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/mariusz/Downloads/AndEngineApp/andEngine/build/intermediates/ndk/release/obj/local/armeabi-v7a/objs/andengine_shared//home/mariusz/Downloads/AndEngineApp/andEngine/src/main/jni/src/GLES20Fix.o: in function Java_org_andengine_opengl_GLES20Fix_glVertexAttribPointer:/home/mariusz/Downloads/AndEngineApp/andEngine/src/main/jni/src/GLES20Fix.c:9: error: undefined reference to 'glVertexAttribPointer' /home/mariusz/android/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/mariusz/Downloads/AndEngineApp/andEngine/build/intermediates/ndk/release/obj/local/armeabi-v7a/objs/andengine_shared//home/mariusz/Downloads/AndEngineApp/andEngine/src/main/jni/src/GLES20Fix.o: in function Java_org_andengine_opengl_GLES20Fix_glDrawElements:/home/mariusz/Downloads/AndEngineApp/andEngine/src/main/jni/src/GLES20Fix.c:13: error: undefined reference to 'glDrawElements' collect2: ld returned 1 exit status make: *** [/home/mariusz/Downloads/AndEngineApp/andEngine/build/intermediates/ndk/release/obj/local/armeabi-v7a/libandengine_shared.so] Error 1 I'm using Android Studio version 0.86.

    Read the article

  • Move Background in AndEngine for a Racing Game

    - by Nathiya
    I am new to game development and AndEngine. I have small query about racing game. I am going to develop a bike racing game. For bike racing game we will move the background or the player. I am tried with andengine autoparallax background. But I didn't got the correct answer. I need to do a background like these screenshots in SpeedMoto. Can anyone help me to set the background.

    Read the article

  • Wheel Joint Implementation in AndEngine

    - by Siddharth
    I am currently developing car game in AndEngine. In which I was using revolute joint for car wheel and chassis attachment. But my friend suggest me that use wheel joint for that purpose for better behavior of the car. In AndEnginen I didn't found the wheel joint implementation. So what I have to do for wheel joint implementation. I think I have to manually update the box2d library for this purpose but I don't know how many things get updated. Please suggest me some guidance on achieving better car behavior in AndEngine.

    Read the article

  • AndEngine GLES2 - getting Black screen on emulator 4.1

    - by dizworld.com
    I'm new in andengine . I create following code public class MainActivity extends BaseGameActivity { static final int CAMERA_WIDTH = 800; static final int CAMERA_HEIGHT = 480; public Font mFont; public Camera mCamera; //A reference to the current scene public Scene mCurrentScene; public static BaseActivity instance; public EngineOptions onCreateEngineOptions() { instance = this; mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); return new EngineOptions(true, ScreenOrientation.LANDSCAPE_SENSOR, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera); } @Override public void onCreateResources(OnCreateResourcesCallback arg0) throws Exception { mFont = FontFactory.create(this.getFontManager(),this.getTextureManager(), 256, 256,Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32); mFont.load(); } @Override public void onCreateScene(OnCreateSceneCallback arg0) throws Exception { mEngine.registerUpdateHandler(new FPSLogger()); mCurrentScene = new Scene(); Log.v("Scene","enter"); mCurrentScene.setBackground(new Background(0.09804f, 0.7274f, 0.8f)); // return mCurrentScene; } @Override public void onPopulateScene(Scene arg0, OnPopulateSceneCallback arg1) throws Exception { // TODO Auto-generated method stub } } I got code on sites there is returning scene but in AndEngine GLES2 in method onCreateScene() there is no return scene ... so my First run is BLACK .. any suggestion :)

    Read the article

  • Making body (box2d) a sprite (andengine) in Android

    - by Kadir
    I can't make body (box2d) a sprite (andengine) and at the same time apply MoveModifier to sprite which is body. If i can make just body, it works namely the sprites can collide. If I apply just MoveModifier to sprites, the sprites can move where i want. But I want to make body (they can collide) and apply MoveModifier (they can move where I want) at the same time. How can i do it? This my code just run MoveModifier not as body at the same time. circles[i] = new Sprite(startX, startY, textRegCircle[i]); body[i] = PhysicsFactory.createCircleBody(physicsWorld, circles[i], BodyType.DynamicBody, FIXTURE_DEF); physicsWorld.registerPhysicsConnector(new PhysicsConnector(circles[i], body[i], true, true)); circles[i].registerEntityModifier( (IEntityModifier) new SequenceEntityModifier ( new MoveModifier(10.0f, circles[i].getX(), circles[i].getX(), circles[i].getY(),CAMERA_HEIGHT+64.0f))); scene.getLastChild().attachChild(circles[i]); scene.registerUpdateHandler(physicsWorld);

    Read the article

  • AndEngine doesn't fill correctly an image on my device

    - by Guille
    I'm learning about AndEngine a little bit, I'm trying to follow a tutorial but I don't get to fill the background image correctly, so, it's just appear in one side of my screen. My device is a Galaxy Nexus (1270x768 I think...). The image is 800x480. The code is: public EngineOptions onCreateEngineOptions() { camera = new Camera(0, 0, 800, 480); EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(), this.camera); engineOptions.getAudioOptions().setNeedsMusic(true).setNeedsSound(true); engineOptions.getRenderOptions().setMultiSampling(true);//.getConfigChooserOptions().setRequestedMultiSampling(true); engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON); return engineOptions; } I have been trying with several values in the camera, but it doesn't fill in all the screen, why?

    Read the article

  • AndEngine Sprite position

    - by Kirill Kulakov
    I had noticed the AndEngine a few days ago, and I tried to create basic game with a few Sprites.Sure, the engine makes the development process much more easier.However I found the sprite lacking a major functionally: Whenever there is a need to refer to the position of an Sprite the engine manipulates the position based on the top-left corner of sprite,this is not the best thing because there is a need to subtract/add the width/height to its position in order to refer to its center.However when we refer to he scale of the Sprite it scaled according to its center point (which is great) I find it very confusing to refer to its position each time differently.I solved that by extending the Sprite class and implementing my methods of setCenter and getCenter, I guess that not the best way to do so. Do you have any suggestion?

    Read the article

  • Making body(box2d) a spite(andengine) in android

    - by Kadir
    I can't make body(box2d) a spite(andengine) and at the same time i wanna apply MoveModifier to sprite which is body.if i can make just body,it works namely the srites can collide.if i can apply just MoveModifier to sprites,the sprites can move where i want.but i wanna make body(they can collide) and apply MoveModifier(they can move where i want) at the same time.How can i do? this my code just run MoveModifier not as body at the same time. circles[i] = new Sprite(startX, startY, textRegCircle[i]); body[i] = PhysicsFactory.createCircleBody(physicsWorld, circles[i], BodyType.DynamicBody, FIXTURE_DEF); physicsWorld.registerPhysicsConnector(new PhysicsConnector(circles[i], body[i], true, true)); circles[i].registerEntityModifier( (IEntityModifier) new SequenceEntityModifier ( new MoveModifier(10.0f, circles[i].getX(), circles[i].getX(), circles[i].getY(),CAMERA_HEIGHT+64.0f))); scene.getLastChild().attachChild(circles[i]); scene.registerUpdateHandler(physicsWorld);

    Read the article

  • AndEngine Foreground Sprite

    - by McGrey
    I'm developing an Android game and have some troubles: I want to add some foreground sprites, that must obstruct my player. Se the following example: Its a screenshot from "Shinobi 3". We can see the player, the enemy, the background and two foreground trees, that hide the player's arm and part of the enemy. I'm using AndEngine GLES2 Anchor Center and I am trying to add a new layer to my scene. Sprite Forest = new Sprite(getWidth() * 0.5f, textureHeightForest * 0.5f + 100, ResourcesManager.getInstance().foreground_forest_region, vbom); Entity foregroundLayer = new Entity(); foregroundLayer.attachChild(hillFurthest); attachChild(foregroundLayer); But it still shows behind my player sprite. I am trying to find something in HUD-class (it's always shown in the foreground), but got no results. Can anyone help please?

    Read the article

  • AndEngine player, background and camera

    - by valdemar593
    I'm developing a 2D shooter using AndEngine. At the moment I'm trying to make the camera follow the player. As I've understood the common approach is to use the SmoothCamera zooming it and setting the chased entity. The problem is that the camera follows the player WITH background moving also (RepeatingSpriteBackground), so it looks like the player doesn't move at all though the actual position changes. So I don't really get how to make the camera follow the player and have the background not moving. Thanks in advance.

    Read the article

  • Physics don't apply on a unique body AndEngine

    - by Kanga
    I am developing a game in AndEngine so far I managed to create everything I wanted for my sprite that was connected to a BoxBody. I was rotating it moving it everything was great. I wanted my collision detection to be more precise so I changed from boxBody to unique irregular shaped body. I found all the vertices and I just replaced the newly created irregular shaped body with the boxbody everywhere in my code. Not only that the image of the sprite is not in place but all the physics and maths I was doing for movement and physics wont work. Please help me :(. Thanks in advance.

    Read the article

  • set TouchEvent to every particle in SpriteParticleSystem in andEngine livewallpaper

    - by Girish Bhutiya
    All I have working on andEngine Live wallpaper and I have use SpriteParticleSystem. I want to add touch event to every Sprite of SpriteParticleSystem and remove that sprite from scene. I have use below code for create particle system. final SpriteParticleSystem particleSystem = new SpriteParticleSystem(new PointParticleEmitter(mParticleX, mParticleY),mParticleMinRate, mParticleMaxRate, mParticleMax,this.mFlowerTextureRegion, this.getVertexBufferObjectManager()); //particleSystem.addParticleInitializer(new BlendFunctionParticleInitializer<Sprite>(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE)); particleSystem.addParticleInitializer(new VelocityParticleInitializer<Sprite>(-90, 0, 0, 0)); particleSystem.addParticleInitializer(new AccelerationParticleInitializer<Sprite>(8, -11)); particleSystem.addParticleInitializer(new RotationParticleInitializer<Sprite>(0.0f, 360.0f)); //particleSystem.addParticleInitializer(new ColorParticleInitializer<Sprite>(1.0f, 1.0f, 0.0f)); particleSystem.addParticleInitializer(new ExpireParticleInitializer<Sprite>(15.5f)); particleSystem.addParticleModifier(new ScaleParticleModifier<Sprite>(0, 5, 0.5f, 2.0f)); background = new Sprite(0, 0, backgroundTextureRegion, mEngine.getVertexBufferObjectManager()); background.setPosition((CAMERA_WIDTH - background.getWidth()) * 0.5f, (CAMERA_HEIGHT - background.getHeight()) * 0.5f); //background.setScale(1.5f); //SpriteBackground bg = new SpriteBackground(background); //mScene.setBackground(bg); this.mScene.attachChild(background); this.mScene.attachChild(particleSystem); <br> Thanks in advance.

    Read the article

  • How to scroll in the physical world AndEngine?

    - by Esteban Quintero
    I am using andengine to make a game where a sprite (player) is going up across the stage, this is my world. final Rectangle ground = new Rectangle(0, CAMERA_HEIGHT - 2, CAMERA_WIDTH, 2, vertexBufferObjectManager); final Rectangle roof = new Rectangle(0, 0, CAMERA_WIDTH, 2, vertexBufferObjectManager); final Rectangle left = new Rectangle(0, 0, 2, CAMERA_HEIGHT, vertexBufferObjectManager); final Rectangle right = new Rectangle(CAMERA_WIDTH - 2, 0, 2, CAMERA_HEIGHT, vertexBufferObjectManager); final FixtureDef wallFixtureDef = PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f); PhysicsFactory.createBoxBody(this.mPhysicsWorld, ground, BodyType.StaticBody, wallFixtureDef); PhysicsFactory.createBoxBody(this.mPhysicsWorld, roof, BodyType.StaticBody, wallFixtureDef); PhysicsFactory.createBoxBody(this.mPhysicsWorld, left, BodyType.StaticBody, wallFixtureDef); PhysicsFactory.createBoxBody(this.mPhysicsWorld, right, BodyType.StaticBody, wallFixtureDef); /* Create two sprits and add it to the scene. */ this.mScene.setBackground(autoParallaxBackground); this.mScene.attachChild(ground); this.mScene.attachChild(roof); this.mScene.attachChild(left); this.mScene.attachChild(right); this.mScene.registerUpdateHandler(this.mPhysicsWorld); The problem is that if the sprite reaches up and hits the wall, as I scroll here?

    Read the article

  • Handling multiple Scene in AndEngine

    - by Asad
    I am Developing a game in AndEngine Gles2. I have splash scene, loading scene, menu scene and Level1 scene. I am using a Screen Manager to manage all scenes through which i can easily switch between splash, loading and menu scene, the level1 scene is also loaded from menu perfectly but problem occur when i go back to menu scene on the completion of level, screen turned to black and nothing shown after that. I think the problem is with unloading the resources of Level1 because the switching between other scene is perfect. I can't give complete code, as it is to much lengthy. I am using bitmapTexture region, Sprites, bodies, physics Word, hud and fixtures etc. here is my unload method.. 1 more thing when i loaded the menu scene at the end of level 1 screen turn to black, but the music played and all logs are showed in logcat which i set in menu scene. unload(){ setChildrenIgnorUpdate(); clearChildScene(); clearEntityModifier(); clearTouchAreas(); clearUpdateHandler(); BitmapTextureManager.getInstance().destroyInstance(); destroyPhysics(); } Please Any help...

    Read the article

  • andEngine dynamic sprites

    - by Blucreation
    Ive just started with andEngine the past week and i only started learning java/android 3 weeks. I can use a for loop to add multiple sprites to the screen but when i try to check collisions on them it only does it to one and not the rest. I want to be able to add a specific number for sprites made from the same texture to the scene, add collision detection to them and also make them slide across the screen (im making a game where you avoid the obstacles). My simple code: private void createobstacle(float pX, float pY) { obstacle = new AnimatedSprite(pX, pY, this.mObjTextureRegion.deepCopy(), getVertexBufferObjectManager()); obstacle.setScale(MathUtils.random(0.5f, 3f)); scene.attachChild(obstacle); } private void createobstacle(int num) { for(int i=0; i<=num; i++ ) { final float xPos = MathUtils.random(30.0f, (CAMERA_WIDTH - 30.0f)); final float yPos = MathUtils.random(30.0f, (CAMERA_HEIGHT - 30.0f)); createobstacle(xPos, yPos); } } Ive read about arrays but i cannot find any tutorials about anything im stuck with. Any help would be great!

    Read the article

  • PhysicsMouseJoint problem in andengine + Box2d

    - by Nikhil Lamba
    What we can remove from this code i.e from PhysicsMouseJointExample to remove the functionality of drag and drog of sprite but i need all functionality except this only user move the sprite with some force and velocity of fling but user can't move the ball as like drag and drop like moving a finger on screen and sprite move with finger plz plz help me I am Using Below method for Mouse Joint CODE : public MouseJoint createMouseJoint(final IShape pFace, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { final Body body = (Body) pFace.getUserData(); final MouseJointDef mouseJointDef = new MouseJointDef(); final Vector2 localPoint = Vector2Pool.obtain((pTouchAreaLocalX - pFace.getWidth() * 0.5f) / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT, (pTouchAreaLocalY - pFace.getHeight() * 0.5f) / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT); this.groundBody.setTransform(localPoint, 0); mouseJointDef.bodyA = this.groundBody; mouseJointDef.bodyB = body; mouseJointDef.dampingRatio = 0.95f; mouseJointDef.frequencyHz = 30; mouseJointDef.maxForce = (200.0f * body.getMass()); mouseJointDef.collideConnected = true; mouseJointDef.target.set(body.getWorldPoint(localPoint)); Vector2Pool.recycle(localPoint); return (MouseJoint)mPhysicsWorld.createJoint(mouseJointDef); }

    Read the article

  • Creating Transparent Game Menu Items using AndEngine

    - by Chaitanya Chandurkar
    I'm trying to create a Game Menu which contains some Menu Items like New Game Multiplayer Options Exit I want to make this Menu Items Transparent. Only Text in White color should be visible. So i guess i do not need any background image for Menu Items. I have seen examples of SpriteButton like given below. ButtonSprite playButton = new ButtonSprite(0, 0, btnNormalTextureRegion, btnPushedTextureRegion, this.getVertexBufferObjectManager(), new OnClickListener() { @Override public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) { // Do Stuff here } } The thing which i don't understand is how can i initialize btnNormalTextureRegion? I use the code give below to initialize ITexture and ITextureRegion for objects. mBackgruondTexture = new BitmapTexture(activity.getTextureManager(), new IInputStreamOpener() { public InputStream open() throws IOException { return activity.getAssets().open("gfx/backgrounds/greenbg.jpg"); } }); mBackgruondTextureRegion = TextureRegionFactory.extractFromTexture(mBackgruondTexture); This code openes up an Image from assest. As i do not want to use any image for Menu Item How can i initialize btnNormalTextureRegion for SpriteButton. OR Is there any alternative to create Game Menu?

    Read the article

  • Andengine put bullet to pull, when it leaves screen

    - by Ashot
    i'm creating a bullet with physics body. Bullet class (extends Sprite class) has die() method, which unregister physics connector, hide sprite and put it in pull public void die() { Log.d("bulletDie", "See you in hell!"); if (this.isVisible()) { this.setVisible(false); mPhysicsWorld.unregisterPhysicsConnector(physicsConnector); physicsConnector.setUpdatePosition(false); body.setActive(false); this.setIgnoreUpdate(true); bulletsPool.recyclePoolItem(this); } } in onUpdate method of PhysicsConnector i executes die method, when sprite leaves screen physicsConnector = new PhysicsConnector(this,body,true,false) { @Override public void onUpdate(final float pSecondsElapsed) { super.onUpdate(pSecondsElapsed); if (!camera.isRectangularShapeVisible(_bullet)) { Log.d("bulletDie","Dead?"); _bullet.die(); } } }; it works as i expected, but _bullet.die() executes TWICE. what i`m doing wrong and is it right way to hide sprites? here is full code of Bullet class (it is inner class of class that represents player) private class Bullet extends Sprite implements PhysicsConstants { private final Body body; private final PhysicsConnector physicsConnector; private final Bullet _bullet; private int id; public Bullet(float x, float y, ITextureRegion texture, VertexBufferObjectManager vertexBufferObjectManager) { super(x,y,texture,vertexBufferObjectManager); _bullet = this; id = bulletId++; body = PhysicsFactory.createCircleBody(mPhysicsWorld, this, BodyDef.BodyType.DynamicBody, bulletFixture); physicsConnector = new PhysicsConnector(this,body,true,false) { @Override public void onUpdate(final float pSecondsElapsed) { super.onUpdate(pSecondsElapsed); if (!camera.isRectangularShapeVisible(_bullet)) { Log.d("bulletDie","Dead?"); Log.d("bulletDie",id+""); _bullet.die(); } } }; mPhysicsWorld.registerPhysicsConnector(physicsConnector); $this.getParent().attachChild(this); } public void reset() { final float angle = canon.getRotation(); final float x = (float) ((Math.cos(MathUtils.degToRad(angle))*radius) + centerX) / PIXEL_TO_METER_RATIO_DEFAULT; final float y = (float) ((Math.sin(MathUtils.degToRad(angle))*radius) + centerY) / PIXEL_TO_METER_RATIO_DEFAULT; this.setVisible(true); this.setIgnoreUpdate(false); body.setActive(true); mPhysicsWorld.registerPhysicsConnector(physicsConnector); body.setTransform(new Vector2(x,y),0); } public Body getBody() { return body; } public void setLinearVelocity(Vector2 velocity) { body.setLinearVelocity(velocity); } public void die() { Log.d("bulletDie", "See you in hell!"); if (this.isVisible()) { this.setVisible(false); mPhysicsWorld.unregisterPhysicsConnector(physicsConnector); physicsConnector.setUpdatePosition(false); body.setActive(false); this.setIgnoreUpdate(true); bulletsPool.recyclePoolItem(this); } } }

    Read the article

  • AndEngine; Box2D - high speed body overlapping, prismatic joints

    - by Visher
    I'm trying to make good suspension for my car game, but I'm getting nervous of some problems with it. At the beginning, I've tried to make it out of one prismatic joint/revolute joint per one wheel only, but surprisingly prismatic joint that should only move in Y asix moves also in X axis, if car travels very fast, or even on low speeds if there's setContinuousPhysics = true. This causes wheels to "shift back", moving them away from axle. Now I've tried to add some bodies that will keep it in place: Suspension helper collides with spring only, wheel doesn't collide with spring&helper&vehicle body This is how I create those elements: rect = new Rectangle(1100, 1350, 200, 50, getVertexBufferObjectManager()); rect.setColor(Color.RED); scene.attachChild(rect); //rect.setRotation(90); Rectangle miniRect1 = new Rectangle(1102, 1355, 30, 50, getVertexBufferObjectManager()); miniRect1.setColor(0, 0, 1, 0.5f); miniRect1.setVisible(true); scene.attachChild(miniRect1); Rectangle miniRect2 = new Rectangle(1268, 1355, 30, 50, getVertexBufferObjectManager()); miniRect2.setColor(0, 0, 1, 0.5f); miniRect1.setVisible(true); scene.attachChild(miniRect2); rectBody = PhysicsFactory.createBoxBody( physicsWorld, rect, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.01f, 10.0f)); rectBody.setUserData("car"); Body miniRect1Body = PhysicsFactory.createBoxBody( physicsWorld, miniRect1, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.01f, 10.0f)); miniRect1Body.setUserData("suspension"); Body miniRect2Body = PhysicsFactory.createBoxBody( physicsWorld, miniRect2, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.01f, 10.0f)); miniRect2Body.setUserData("suspension"); physicsWorld.registerPhysicsConnector(new PhysicsConnector(rect, rectBody, true, true)); physicsWorld.registerPhysicsConnector(new PhysicsConnector(miniRect1, miniRect1Body, true, true)); physicsWorld.registerPhysicsConnector(new PhysicsConnector(miniRect2, miniRect2Body, true, true)); PrismaticJointDef miniRect1JointDef = new PrismaticJointDef(); miniRect1JointDef.initialize(rectBody, miniRect1Body, miniRect1Body.getWorldCenter(), new Vector2(0.0f, 0.3f)); miniRect1JointDef.collideConnected = false; miniRect1JointDef.enableMotor= true; miniRect1JointDef.maxMotorForce = 15; miniRect1JointDef.motorSpeed = 5; miniRect1JointDef.enableLimit = true; physicsWorld.createJoint(miniRect1JointDef); PrismaticJointDef miniRect2JointDef = new PrismaticJointDef(); miniRect2JointDef.initialize(rectBody, miniRect2Body, miniRect2Body.getWorldCenter(), new Vector2(0.0f, 0.3f)); miniRect2JointDef.collideConnected = false; miniRect2JointDef.enableMotor= true; miniRect2JointDef.maxMotorForce = 15; miniRect2JointDef.motorSpeed = 5; miniRect2JointDef.enableLimit = true; physicsWorld.createJoint(miniRect2JointDef); scene.attachChild(karoseriaSprite); Rectangle r1 = new Rectangle(1050, 1300, 52, 150, getVertexBufferObjectManager()); r1.setColor(0, 1, 0, 0.5f); r1.setVisible(true); scene.attachChild(r1); Body r1body = PhysicsFactory.createBoxBody(physicsWorld, r1, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.001f, 0.01f)); r1body.setUserData("suspensionHelper"); physicsWorld.registerPhysicsConnector(new PhysicsConnector(r1, r1body, true, true)); WeldJointDef r1jointDef = new WeldJointDef(); r1jointDef.initialize(r1body, rectBody, r1body.getWorldCenter()); physicsWorld.createJoint(r1jointDef); Rectangle r2 = new Rectangle(1132, 1300, 136, 150, getVertexBufferObjectManager()); r2.setColor(0, 1, 0, 0.5f); r2.setVisible(true); scene.attachChild(r2); Body r2body = PhysicsFactory.createBoxBody(physicsWorld, r2, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.001f, 0.01f)); r2body.setUserData("suspensionHelper"); physicsWorld.registerPhysicsConnector(new PhysicsConnector(r2, r2body, true, true)); WeldJointDef r2jointDef = new WeldJointDef(); r2jointDef.initialize(r2body, rectBody, r2body.getWorldCenter()); physicsWorld.createJoint(r2jointDef); Rectangle r3 = new Rectangle(1298, 1300, 50, 150, getVertexBufferObjectManager()); r3.setColor(0, 1, 0, 0.5f); r3.setVisible(true); scene.attachChild(r3); Body r3body = PhysicsFactory.createBoxBody(physicsWorld, r3, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(1f, 0.01f, 0.01f)); r3body.setUserData("suspensionHelper"); physicsWorld.registerPhysicsConnector(new PhysicsConnector(r3, r3body, true, true)); WeldJointDef r3jointDef = new WeldJointDef(); r3jointDef.initialize(r3body, rectBody, r3body.getWorldCenter()); physicsWorld.createJoint(r3jointDef); MouseJointDef md = new MouseJointDef(); Sprite wheel1 = new Sprite( miniRect1.getX()+miniRect1.getWidth()/2-wheelTexture.getWidth()/2, miniRect1.getY()+miniRect1.getHeight()-wheelTexture.getHeight()/2, wheelTexture, engine.getVertexBufferObjectManager()); scene.attachChild(wheel1); Body wheel1body = PhysicsFactory.createCircleBody( physicsWorld, wheel1, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.01f, 5.0f)); wheel1body.setUserData("wheel"); Shape wheel1shape = wheel1body.getFixtureList().get(0).getShape(); wheel1shape.setRadius(wheel1shape.getRadius()*(3.0f/4.0f)); physicsWorld.registerPhysicsConnector(new PhysicsConnector(wheel1, wheel1body, true, true)); Sprite wheel2 = new Sprite( miniRect2.getX()+miniRect2.getWidth()/2-wheelTexture.getWidth()/2, miniRect2.getY()+miniRect2.getHeight()-wheelTexture.getHeight()/2, wheelTexture, engine.getVertexBufferObjectManager()); scene.attachChild(wheel2); Body wheel2body = PhysicsFactory.createCircleBody( physicsWorld, wheel2, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.01f, 5.0f)); wheel2body.setUserData("wheel"); Shape wheel2shape = wheel2body.getFixtureList().get(0).getShape(); wheel2shape.setRadius(wheel2shape.getRadius()*(3.0f/4.0f)); physicsWorld.registerPhysicsConnector(new PhysicsConnector(wheel2, wheel2body, true, true)); RevoluteJointDef frontWheelRevoluteJointDef = new RevoluteJointDef(); frontWheelRevoluteJointDef.initialize(wheel1body, miniRect1Body, wheel1body.getWorldCenter()); frontWheelRevoluteJointDef.collideConnected = false; RevoluteJointDef rearWheelRevoluteJointDef = new RevoluteJointDef(); rearWheelRevoluteJointDef.initialize(wheel2body, miniRect2Body, wheel2body.getWorldCenter()); rearWheelRevoluteJointDef.collideConnected = false; rearWheelRevoluteJointDef.motorSpeed = 2050; rearWheelRevoluteJointDef.maxMotorTorque= 3580; physicsWorld.createJoint(frontWheelRevoluteJointDef); Joint j = physicsWorld.createJoint(rearWheelRevoluteJointDef); rearWheelRevoluteJoint = (RevoluteJoint)j; r1body.setBullet(true); r2body.setBullet(true); r3body.setBullet(true); miniRect1Body.setBullet(true); miniRect2Body.setBullet(true); rectBody.setBullet(true); at low speeds, it's OK, but on high speed vehicle can even flip around on flat ground.. Is there a way to make this work better?

    Read the article

  • setPosition of Sprite onUpdate in AndEngine

    - by SSH This
    I am trying to get a "highlighter" circle to follow around a sprite, but I am having trouble, I thought I could use the onUpdate method that's available to me in SequenceEntityModifier but it's not working for me. Here is my code: // make sequence mod with move modifier SequenceEntityModifier modifier = new SequenceEntityModifier(myMovemod) { @Override protected void onModifierFinished(IEntity pItem) { // animation finished super.onModifierFinished(pItem); } public float onUpdate(float pSecondsElapsed, IEntity pItem) { highlighter.setPosition(player2.getX() - highlighterOffset, player2.getY() - highlighterOffset); return pSecondsElapsed; } }; When onUpdate is completely commented out, the sprite moves like I want it to, everything is ok. When I put the onUpdate in, the sprite doesn't move at all. I have a feeling that I am overriding the original onUpdate's actions? Am I going about this the wrong way? I am new to Java, so please feel free to advise if this isn't going to work. UPDATE: The player2 is the sprite that I'm trying to get the highlighter to follow.

    Read the article

  • AndEngine Box2d game

    - by OneMoreVladimir
    I'm developing a 2d survival shooter using Box2d extension and I've got some questions: I have two AnalogOnScreenControls. Their listeners modify both sprites and bodies. I receive TouchEventPool was exhausted and as their number grows the game crashes accidently. I've tried to put the modification of the bodies and sprites on the UpdateThread but that does not solve the problem. What could be the cause? I have a class that at the beginnig of the game loads all the textures. After I relaunch the game activity several times I receive Unable to find Phys Addr for and "green color" interface. But that doesn't happen if I clear the memory manually through the Task Manager before relaunch What could be the cause? I unload my atlas at the end of the game. The game sometimes crashes at start with NullPointerException in onResumeGame. The solution suggested is to set android:configChanges="orientation|screenSize" but my device is API 10 so it doesn't have screenSize property and orientation only does not seem to help, because the game starts in portrait mode at times (though landscape is set in the code)

    Read the article

  • How to optimise Andengine's PathModifer (with singleton or pool)?

    - by Casla
    I am trying to build a game where the character find and follows a new path when a new destination is issued by the player, kinda like how units in RTS games work. This is done on a TMX map and I am using the A Star path finder utilities in Andengine to do this.David helped me on that: How can I change the path a sprite is following in real time? At the moment, every-time a new path is issued, I have to abandon the existing PathModifer and Path instances, and create new ones, and from what I read so far, creating new objects when you could re-use existing ones are a big waste for mobile applications. This is how I coded it at the moment: private void loadPathFound() { if (mAStarPath != null) { modifierPath = new org.andengine.entity.modifier.PathModifier.Path(mAStarPath.getLength()); /* replace the first node in the path as the player's current position */ modifierPath.to(player.convertLocalToSceneCoordinates(12, 31)[Constants.VERTEX_INDEX_X]-12, player.convertLocalToSceneCoordinates(12, 31)[Constants.VERTEX_INDEX_Y]-31); for (int i=1; i<mAStarPath.getLength(); i++) { modifierPath.to(mAStarPath.getX(i)*TILE_WIDTH, mAStarPath.getY(i)*TILE_HEIGHT); /* passing in the duration depended on the length of the path, so that the animation has a constant duration for every step */ player.registerEntityModifier(new PathModifier(modifierPath.getLength()/100, modifierPath, null, mIPathModifierListener)); } } The ideal implementation will be to always have just one object of PathModifer and just reset the destination of the path. But I don't know how you can apply the singleton patther on Andengine's PathModifer, there is no method to reset attribute of the path nor the pathModifer. So without re-write the PathModifer and the Path class, or use reflection, is there any other way to implement singleton PathModifer? Thanks for your help.

    Read the article

  • AndEngine VS Android's Canvas VS OpenGLES - For rendering a 2D indoor vector map

    - by Orchestrator
    This is a big issue for me I'm trying to figure out for a long time already. I'm working on an application that should include a 2D vector indoor map in it. The map will be drawn out from an .svg file that will specify all the data of the lines, curved lines (path) and rectangles that should be drawn. My main requirement from the map are Support touch events to detect where exactly the finger is touching. Great image quality especially when considering the drawings of curved and diagonal lines (anti-aliasing) Optional but very nice to have - Built in ability to zoom, pan and rotate. So far I tried AndEngine and Android's canvas. With AndEngine I had troubles with implementing anti-aliasing for rendering smooth diagonal lines or drawing curved lines, and as far as I understand, this is not an easy thing to implement in AndEngine. Though I have to mention that AndEngine's ability to zoom in and pan with the camera instead of modifying the objects on the screen was really nice to have. I also had some little experience with the built in Android's Canvas, mainly with viewing simple bitmaps, but I'm not sure if it supports all of these things, and especially if it would provide smooth results. Last but no least, there's the option of just plain OpenGLES 1 or 2, that as far as I understand, with enough work should be able to support all the features I require. However it seems like something that would be hard to implement. And I've never programmed in OpenGL or anything like it, but I'm willing very much to learn. To sum it all up, I need a platform that would provide me with the ability to do the 3 things I mentioned before, but also very important - To allow me to implement this feature as fast as possible. Any kind of answer or suggestion would be very much welcomed as I'm very eager to solve this problem! Thanks!

    Read the article

  • andengine - how to make the game wait for an animation to finish?

    - by petervaz
    I'm teaching myself andengine while trying to make a match-3 puzzle, so far I have a grid of gems that I populate and can move then around. Matching gems and new gems falling is working already. My problem is that the game keeps flowing while animations runs. How can I make the flow suspend until movement is done? I use entity modifiers for the gems animations. MoveYModifier for the fall and PathModifier for the swap.

    Read the article

  • RevoluteJoint Stop Rotating when Some Physics Body Collide in Andengine + Box2d?

    - by Nikhil Lamba
    I am making a Game from andengine + box2d in Which i am using RevoluteJoint in that case i am facing some problem that when physics body or Sprite Collide with this Revolute joint body then Revolute body stop rotating then after some time it start rotating I am using below code for this : this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(movingFace, movingBody, true, true)); final RevoluteJointDef revoluteJointDef = new RevoluteJointDef(); revoluteJointDef.initialize(anchorBody, movingBody, anchorBody.getWorldCenter()); revoluteJointDef.enableMotor = true; revoluteJointDef.motorSpeed = 100; revoluteJointDef.maxMotorTorque = 200; this.mPhysicsWorld.createJoint(revoluteJointDef); EDIT Here is a screenshot:

    Read the article

1 2 3 4  | Next Page >