Entitymodifiers do not work (AndEngine / Android)

I play with AndEngine. No documents to read, so I'm just shooting in the dark.

Finally a splash screen appeared. Now I'm trying to add some transitions to it, but no luck here. Here is the code:

@Override public void onLoadComplete() { mHandler.postDelayed(fadeAway, 2500); } protected Runnable fadeAway = new Runnable() { @Override public void run() { // The only child of the scene is our splash sprite scene.getLastChild().registerEntityModifier(new SequenceEntityModifier( new ScaleModifier(2500, 100.0f, 200.0f), new RotationModifier(2500, 0.0f, 78.0f), new AlphaModifier(2500, 1.0f, 0.0f) )); } }; 

It happens that postDelayed() works fine (waiting 2.5 seconds), but then everything immediately turns black. I expected that the splash screen should increase to 200%, then rotate 78 degrees, then turn off, but since everything turns black, it feels that the duration of the modifiers is not working.

Is there a clear mistake here?

EDIT : Well, I found errors: 1) Apparently, pDuration (first argument) should be in seconds, not milliseconds, like everywhere else. 2) In ScaleModifier () 1.0f, the original size is equal, so the argument is not in percent, as expected.

(There is no flame, but I am really amazed at how people managed to learn how to use this library without any documentation. There are no comments or notes in the entire source code. Have people tried and erroneously designed everything to find out how should it work? I can’t believe that the author put this huge work for this library and never provided any documents.)

+4
source share
1 answer

Your errors are listed below:

  • All durations in AndEngine are in seconds.
  • Normal scale 1.0f not 100.0f .
  • Android Handler is not necessary. You should delay your work in the onUpdate methods of the engine or other AndEngine materials.
  • You should only apply animation in the update thread anywhere. mEngine.runOnUpdateThread(...)
0
source

Source: https://habr.com/ru/post/1399589/


All Articles