Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor Danack's Avatar
    Join Date
    May 2003
    Posts
    151
    Is it possible to get rid of the title on the canvas without using any Nokia specific libraries ?

    I'm developing a game that's hopefully going to be on a number of different phones and I'd rather not have different code for each phone....

  2. #2
    Regular Contributor tinkezione's Avatar
    Join Date
    Mar 2003
    Location
    Helsinki.FI
    Posts
    112
    Hi,

    with Nokia phones, it's unfortunately it's not possible to get rid of the Canvas title without using the FullCanvas class of Nokia UI API. Don't know about the other manufacturers, though.

    Kind regards
    Tinke / FN

  3. #3
    Regular Contributor Danack's Avatar
    Join Date
    May 2003
    Posts
    151
    Thanks

    Do you have any advice on how to implement platform dependent code such as this ? For example if I was writing platform independent C code I'd do:

    #ifdef NOKIA_PLATFORM
    class GameFrame extends FullCanvas
    #else
    class GameFrame extends Canvas
    #endif
    {
    ...rest of class
    }


    Obviously that's not possible on Java as it doesn't have the pre-processor. Is there anyway of not having either lines of code commented in/out or completely different source files.

    cheers
    dan

  4. #4
    Registered User Nightmare_82's Avatar
    Join Date
    Apr 2003
    Posts
    7
    I have 3 canvas classes in my engine. One for Nokia, one for Siemens and the standard one.
    In the different jar files you only put the one you need and with
    Class.forName("com.nokia.mid.ui.FullCanvas");
    you can test if a class exists(if its a nokia handy) and create an instance of it. The problem is that you have to copy the code from the 3 classes, but you only need one canvas and you don't have to change the code.

    Code:
            try
            {
                // This statement throws an exception if no Nokia UI API available
                Class.forName("com.nokia.mid.ui.FullCanvas");
                        Class clas = Class.forName("escape.api.graphics.nokia.CNokiaCanvas");
                
                oCanvas = (IEscCanvas)(clas.newInstance());
                
                System.out.println("Nokia Canvas");
            }
            catch (Exception e)
            {
                try
                {
                    // If no Nokia UI API, then create a  SiemensCanvas                
                    Class.forName("com.siemens.mp.color_game.GameCanvas");
                    
                    Class clas = Class.forName("escape.api.graphics.siemens.CSiemensCanvas");
                    
                    oCanvas = (IEscCanvas)(clas.newInstance());
                    
                    System.out.println("Siemens Canvas");
                }
                catch (Exception e2)
                {               
                    oCanvas = (IEscCanvas) new CEscCanvas();
                    
                    System.out.println("Standard Canvas");
                }

  5. #5
    Regular Contributor Danack's Avatar
    Join Date
    May 2003
    Posts
    151
    Thanks - What I'm doing now is having different files that define 'GameCanvas' and then extend that class eg

    NokiaCanvas.java:
    class GameCanvas extends FullCanvas
    {
    //nokia specific stuff
    }


    StandardCanvas.java:
    class GameCanvas extends Canvas
    {
    // default version stuff.
    }


    then in my actual game code I extend GameCanvas:

    I use Metrowerks Codewarrior Wireless studio, which allows you to include different files for different build targets. So for the Nokia build target it includes NokiaCanvas.java and for the standard version it includes StandardCanvas.java.


    This is cool as it also allows me to separate other platform specific stuff into this file eg Nokia and Motorola disagree on what the button IDs for the softkeys should be.

    cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved