Menu Screen

Forum for J2ME mobile games related topics including programming doubts, books and other resources for J2ME game development

Menu Screen

Postby thinkandapply » Mon Dec 01, 2008 12:51 pm

How do i make the menu scrren for my game .
thinkandapply
 
Posts: 15
Joined: Wed Nov 05, 2008 5:42 pm

Re: Menu Screen

Postby DevelopmentTeam » Tue Dec 02, 2008 4:51 am

Search within this forum and in google and you will definitely get basic opensource games from which you can start learning.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: Menu Screen

Postby thinkandapply » Wed Dec 03, 2008 2:38 pm

How do i dispaly a multi line string on the screen of a mobile device,
i uset this way
String str="This is a simple text/n"+"but dosent display multiline";
thinkandapply
 
Posts: 15
Joined: Wed Nov 05, 2008 5:42 pm

Re: Menu Screen

Postby thinkandapply » Wed Dec 03, 2008 2:41 pm

how do i scroll the string upword continously on the screen.
thinkandapply
 
Posts: 15
Joined: Wed Nov 05, 2008 5:42 pm

Re: Menu Screen

Postby MobAppDeathFromHell » Tue Jan 20, 2009 7:09 am

thinkandapply wrote:How do i display a multi line string on the screen of a mobile device,
i used this way
String str="This is a simple text/n"+"but doesn't display multiline";

J2ME doesn't support '/n' as the code for line break.
Well you can actually emulate one yourself:
Here's how i did it, (i coded this myself ^^)
Code: Select all
private void TextOut(String text, Graphics g, int x, int y, int textSize, int color) {
        int previousColor = g.getColor();
        String cmdBreakText = "/n";
        int lineNo = 0;
        String[] strLine = new String[6];
        int charLineAt = 0;
       
        // go through each char in a text
        for (int i = 0; i < text.length() - cmdBreakText.length(); i++) {
            // check if that text contain the command break
            if ( text.substring( i, i + cmdBreakText.length() ).equals(cmdBreakText)) {
                strLine[lineNo] = text.substring( charLineAt, i );
                // for the next check, begin after the cmd break text
                charLineAt = i+cmdBreakText.length();
                // get the total lines (-1)
                lineNo++;
            }
        }
        strLine[lineNo] = text.substring( charLineAt, text.length() );
       
        // set paint color
        g.setColor(color);

        for (int i = 0; i < lineNo+1; i++) {
            g.drawString(strLine[i], x, y + i*textSize, Graphics.LEFT|Graphics.TOP);
        }
       
        // set paint to previous color
        g.setColor(previousColor);
}

Use it this way:

Code: Select all
TextOut("Hello world! /nWelcome to /nhttp://www.smackall.com/mobile-game-developer//nHave a nice day! ^^", g, 50, 50, 12, 0x0000FF);

Parameter is
TextOut(
<YOUR TEXT>,
<Graphic>,
<X position>,
<Y position>,
<pixels to move down>,
<Color in int> );

It should output as:

Hello world!
Welcome to
http://www.smackall.com/mobile-game-developer/
Have a nice day! ^^

Tell me how useful. ^^
MobAppDeathFromHell
 
Posts: 2
Joined: Tue Jan 20, 2009 4:12 am


Return to J2ME Games

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 1 guest

cron