J2ME.游戏画布形式切换 [英] J2ME. Game Canvas Form switching

查看:98
本文介绍了J2ME.游戏画布形式切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个游戏画布和一个表单.我使用display.setCurrent[<gamecanvas>]</gamecanvas>将控件切换到GameCanvas,如何从GameCanvas切换到Form?无法使用display.setCurrent?请帮帮我.

I have created a game canvas and a form. I switch control to the GameCanvas using display.setCurrent[<gamecanvas>]</gamecanvas> how do i switch from GameCanvas to Form ? unable to use display.setCurrent? Please help me out.

推荐答案

您需要留下一些面包屑,以找到返回Midlet的方式来查找其显示内容(和表单).遵循以下原则:

You need to leave some breadcrumbs to find your way back to your Midlet to find its display (and the form). Something along these lines:

public class myMIDlet extends MIDlet implements ... {
...
Form myForm = new Form( ... 
...
myGameCanvas ggg = new myGameCanvas(... , this) // <=== note the last parameter - the key to it all
...
display.setCurrent(ggg);
...
}

class myGameCanvas extends GameCanvas implements ... {
myMIDlet myHost; // the breadcrumb

    public myGameCanvas(... , myMIDlet host) {
    super(...);
    myHost = host; // remember our host MIDlet
    ...
    }

    ... wherever you want to got to the form (probably in a commandAction or keyPressed)
    Display disp = myHost.getDisplay();
    disp.setCurrent(myHost.myForm);

}



干杯,
彼得
如果这回答了您的问题,请将其标记为已接受.仍要投票.



Cheers,
Peter
If this answers your question, mark it as accepted. Vote anyway.


这篇关于J2ME.游戏画布形式切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆