Create Landscape Game Canvas for Asha 303

让人想犯罪 __ 提交于 2019-12-01 10:20:46

问题


i've searched all the forum bet never found any answer satisfy my question.

I want to create a game with landscape orientation for Nokia Asha 303, are there any way to rotate the game canvas 90 degrees so the orientation become landscape orientation? Because i look at this video Angry Bird Asha 303. The game has landscape orientation so i curious how to do that in j2me.

Thanks,


回答1:


Since MIDP 2.0 we can use an Sprite to rotate an image in 90 degrees. First thing we need is an Image of the correct size. Following code could be inside the constructor of a class that extends Canvas - considering an Sprite and an Image attributes:


    int width = Math.max(super.getWidth(), super.getHeight());
    int height = Math.min(super.getWidth(), super.getHeight());
    screen = Image.createImage(width, height);
    sprite = new Sprite(screen);
    if (super.getWidth() < super.getHeight()) { // portrait screen
        sprite.setTransform(Sprite.TRANS_ROT90);
        sprite.setPosition(0, 0);
    }

When painting your content use the mutable Image Graphics, then update the sprite with the image like bellow.


    protected void paint(Graphics g1) {
        Graphics g = screen.getGraphics();
        // ... do your drawing
        this.sprite.setImage(screen, screen.getWidth(), screen.getHeight());
        sprite.paint(g1);
    }

How can you use the biggest possible area on the handset display?
. Do not setTitle on your Canvas
. Do not addCommand to your Canvas
. Call setFullScreenMode(true) before calling super.getWidth() and super.getHeight()

From http://smallandadaptive.blogspot.com.br/2009/08/fullscreen-landscape.html



来源:https://stackoverflow.com/questions/10923801/create-landscape-game-canvas-for-asha-303

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!