just clone my repo and get the niffy branch
https://github.com/Niffy/AndEngine.git
FixedStepMaxFPSEngine
https://github.com/Niffy/AndEngine/comm ... 7bc43b26be
Want to have a constant update speed but maximum FPS without linking the two? Well now you can with this engine!
When creating a new engine use the following. This will fire 25 updates a seconds, put what you want.
Using java Syntax Highlighting
- new FixedStepMaxFPSEngine(pEngineOptions, 25);
Parsed in 0.029 seconds, using GeSHi 1.0.8.4
Then to get the constant update you just register to a different handler.
So create a TimerHandler, like you normally would.
Using java Syntax Highlighting
- TimerHandler mTimeHandler = new TimerHandler(5, new ITimerCallback() {
- @Override
- public void onTimePassed(TimerHandler arg0) {
- //do some stuff
- }
- });
- this.mEngine.registerConstantUpdateHandler(this.mTimeHandler);
- this.mEngine.unregisterConstantUpdateHandler(this.mTimeHandler);
- this.mEngine.clearConstantUpdateHandlers();
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
You can still use the standard way of updates if you like, but I've implemented this so I can at least get a constant speed across different devices. I've no idea or intention of using this engine with Physics
Fragment Activity
https://github.com/Niffy/AndEngine/comm ... 8a3faaa746
lintfordpickle used Fragments, he posted some code which I've not yet looked at as before hand I published my own on github, his is probably very similar if not the same as Andengine GLES1 had this activity, not GLES2 never got it.
So thanks to lintfordpickle for kick starting this and providing help and details on his game! < Check out his game and thread!
Updated: 18/05/2012
http://www.youtube.com/watch?v=sr9RdwXlf1A
^Example of using LayoutGameFragment
The packages are
org.andengine.ui.activity.fragments.BaseGameFragment
org.andengine.ui.activity.fragments.LayoutGameFragment
org.andengine.ui.activity.fragments.compatibility.BaseGameFragment
org.andengine.ui.activity.fragments.compatibility.LayoutGameFragment
Use the compatibility classes if you're below API Level 11,
I strongly suggest you read the following links, this is where you can learn fragments(That's how I did it!)
http://developer.android.com/sdk/compat ... brary.html
http://developer.android.com/guide/topi ... ments.html
You extend the LayoutGameFragment class and implement the following
Using java Syntax Highlighting
- protected int getLayoutID() {
- return R.layout.main;
- }
- @Override
- protected int getRenderSurfaceViewID() {
- return R.id.xmllayoutexample_rendersurfaceview;
- }
- @Override
- protected void onSetContentView() {
- super.onSetContentView();
- }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
Here is a basic XML layout (res/layout/main.xml)
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="UTF-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="0px"
- android:layout_weight="1" >
- <!-- <org.andengine.opengl.view.RenderSurfaceView -->
- <!-- <android.opengl.GLSurfaceView -->
- <org.andengine.opengl.view.RenderSurfaceView
- android:id="@+id/xmllayoutexample_rendersurfaceview"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- <!-- This is where you then add your other layouts!-->
- </FrameLayout>
- </LinearLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
Remember to add all your thingy bobs inside the framelayout!
If you want to see how things are looking graphical in the editor, then swap
Using java Syntax Highlighting
- <org.andengine.opengl.view.RenderSurfaceView
- with
- <android.opengl.GLSurfaceView
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
Remember to swap back when you want to run the game
This is useful if you'd like to prototype quickly, but useless when using fragments.
When setting engine options use a FillResolutionPolicy, otherwise you might find the GL surface doesn't really fill the screen.
From here on you can start using fragments! (Remember learn how to use them!)
Bugs
Bound to be some,
do post them, but I cannot guarantee to get around to fixing the.
If you do find a solution to one then please post.
Updated: 25/08/2012
Created a new shader to use with andengine, rather simply but useful for some people. A dual palette swap shader, you can swap one colour with another and if you want, swap another colour with another.
https://github.com/Niffy/DualPaletteSwapShader
https://github.com/Niffy/DualPaletteSwapShaderExample
Updated: 26/08/2012
FixedStepMaxFPSEngine updated so you can pause the scene and updates.
Updated: 28/08/2012
AndEngineTMXTiledMapExtension Isometric branch updated. You can now have a map draw origin, might come in handy if you want to stitch maps together in a scene! TMXLayerObjectTitles, ConvertIsometricPixelToScene, TMXLayer now take in to account the map draw origin when converting polypoints, getting tile at touch point.
Updated: 08/10/2012
Quite a bit of AStarPathing work in package org.andengine.util.algorithm.path.astar.tile
You can now stop the AStarPathTileModifier, it doesn't stop all together, it stops after the current subsequence has finished. (to stop it all together just unregister like before). This makes it easy for path finding, since path finding is tile based and so is movement(centre of tile to centre of tile)
New modifier which can move an entity from A to C with the Z index changing at B! Useful for isometric movement...
Engine, FixedStepMaxFPSEngine, Entity can now handle a time modifier, so you can increase the update speed of entities and constant update handlers, but it would be easy to include the normal update handlers into this increase. This will enable you increase the updates, ie implement a speed up and slow down game functions.
So on each update we can multiply by the time modifier to increase the seconds elapsed. You can call on the engine.
Using java Syntax Highlighting
- setTimeModifer(final int pTimeModifier)
- int getTimeModifier(); //get the time modifier (this is also for implementing ITimeModifiedUpdater)
- increaseTimeModifier() //Increase by 1
- decreaseTimeModifier() //decrease by 1, lowest it can go is 1
- resetTimeModifier() //set back to 1
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
On the entity you can call
Using java Syntax Highlighting
- registerForTimeModifier(boolean pRegisterForTimeModifier) //call this on things such as sprites
- setTimeModifedUpdater(ITimeModifiedUpdater pTimeModifiedUpdater) //Just pass the engine you are using since the engine implements the required interface
- boolean isRegisteredForTimeModifier() //Is the entity registered for a time modified update?
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
Never register a scene for a time modified update(since it is derived from Entity), so never call scene.registerForTimeModifier(true); Although if you know what you're attaching to your scene then you can do this so all its children get update quicker. The reason I this is because I found that applying the time modifier on updating the scene caused a decrease in FPS, I assume its on the runnable's attached to the scene and/or large spritebatches (like a TMXLayer)
But you do have to call setTimeModifedUpdater on the scene and pass the engine
So when you attach (or before) a sprite to a scene, say an animated sprite, just remember to call registerForTimeModifier(true), then any modifiers you apply will automatically increase.
Updated: 18/03/2013
You can have an isometric world now!
Simply grab my branches (they have been updated)
Grab the example
https://github.com/Niffy/IsometricWorldExample
https://github.com/Niffy/IsometricWorldExample/wiki
Look at the wiki and the code to understand what s going on.
Oh and there it uses fragments!!! - The wiki does not explain fragments as this is a standard Android feature.
