J2ME Manager.CreatePlayer() freeze application for a split second when using the first time

StackOverflow https://stackoverflow.com/questions/23207902

  •  07-07-2023
  •  | 
  •  

Pergunta

When I call for the first time to Manager.CreatePlayer() its freezes my application for a split second and it's a problem for me because I'm writing a game and it's noticeable, what can I do to fix it ?

Foi útil?

Solução

As far as I know, the common logics for game are :

Display loading screen

Here's all heavy operations are prepared/preloaded and cached, so the game can run smoothly later. Methods that usually called here are Manager.createPlayer and Player.prefetch(). All the image & sound is prepared first, and can be used quickly when game started.

Start the game (loop)

As the resource have been prepared/preloaded, now you can use (draw/play) them here. Use the Player instances that has been created & prefetched (from loading screen). You can call Player.start() method here to play the sound.


You can read about the Player state (especially about prefetch) HERE.

Notice that you can reuse the Player instance and call start() method multiple times for playing the same sound. No need to call createPlayer again.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top