扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
public class GameMIDlet extends MIDlet { static GameMIDlet instance; Display display; GameDisplayable displayable = null; public GameMIDlet() { instance = this; display = Display.getDisplay(this); displayable = new GameDisplayable(); } public void startApp() { display.setCurrent(displayable); } public void pauseApp() { } public void destroyApp(boolean unconditional) { displayable.running = false; } public static void quitApp() { instance.destroyApp(true); instance.notifyDestroyed(); instance = null; } } public class GameDisplayable extends FullCanvas implements Runnable { /** 主控制线程 */ Thread MainThread = null; /** 游戏时钟间隔 毫秒为单位 */ public static long timeinterval = 20; public static boolean Isstable = true; /* 用于游戏时钟的变量 */ public static long timeold = 0; public static long timenow = 0; public long interval = 0; public static long frames_per_second = 0; int count = 0; long second = 0; public static boolean running = true; public GameDisplayable() { // 开始主线程 Thread MainThread = new Thread(this); MainThread.start(); } public void run() { while (running) { timenow = System.currentTimeMillis(); interval = timenow - timeold; if (interval >= timeinterval) { timeold = timenow; Game_Process(); if (second != (System.currentTimeMillis() / 1000)) { second = System.currentTimeMillis() / 1000; frames_per_second = count; count = 1; } else count++; } lib.sleep(30); } } |
public class GameMIDlet extends MIDlet { GameDisplayable displayable = null; /** 游戏时钟间隔 毫秒为单位 */ public static long timeinterval = 0; //用于游戏时钟的变量 public static long timeold = 0; public static long timenow = 0; public long interval = 0; public static long frames_per_second=0; int count=0; long second =0; public static boolean running = false; static boolean exitApp =false; public GameMIDlet() { displayable = new GameDisplayable(); running =true; } public void startApp() { running =true; Display.getDisplay(this).setCurrent(displayable); while(running) { timenow = System.currentTimeMillis(); interval = timenow - timeold; if (interval >= timeinterval) { timeold = timenow; displayable.Game_Process(); if(second != (System.currentTimeMillis() /1000)){ second = System.currentTimeMillis()/1000; frames_per_second = count; count = 1; }else count ++; } } if(exitApp) { destroyApp(true); notifyDestroyed(); } } public void pauseApp() { running =false; } public void destroyApp(boolean unconditional) { running = false; } public static void quitApp() { running =false; exitApp =true; } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者