Hello all!
I havn’t been back here for quite some time, but I have one that is stumping me for the moment. My name is Adam Schmelzle, and I have been making J2ME games for a while(Attack Chopper 1/2, Attack Breaker Pro, Attack Brain), so I’m not really new to this.
I am working on an online system for my next game, and all my messaging is done through an HttpConnection for now. I am trying to make this compatible with Midp1.0, which is why I am using http. I have everything working fine on the Sun WTK25, but when it comes to using my phones, I run into problems with my canvas.keypressd() events.
Sometimes the keypresses/releases will work fine, sometimes a delay of a second or two, sometimes it won’t fire until I hit some buttons a few times.
Example 1: So I can press and hold “up”, get the “up-pressed” event, wait a couple seconds then release, but not get the “up-release” event. If I press “up” again I don’t get the “up-pressed” event at all, but when I release I finally get the original “up-release” from the first keypress.
Example 2: Press “up”, get “up-pressed” event. Release “up”, and never get the “released-up” event at all.
This only happens if my network IO thread is sending/receiving data. On one of my phones I experience problems for the entire duration of my game after even doing just 1 httpConnection on the main game thread.
I guess I want to know if anybody has some advice for me regarding network IO. I assume that somewhere along the line the runtime is starving the thread that handles the keypresses, but is there any way to avoid this? Maybe sleeping/waiting briefly(1ms) in the middle of transfering data every once in a while? It does take a second or two to send/recieve.
I plan on implementing socket IO for Midp2.0 phones after I’ve got all the kinks worked out for Midp1.0. My server will use nio, which I have used before in an applet game with positive results.
Help please,
Adam.