You Are Here:

Community: Developer Discussion Boards

#1 Old Screensize in MIDP2.0 GameCanvas class - 2005-03-29, 11:25

Join Date: Jun 2004
Posts: 7
teric
Offline
Registered User
I have the following problem with a Nokia series 60 device:

I'm using the MIDP2.0 GameCanvas class and set it to fullscreen like this:

myCanvas = new Canvas(this);
myCanvas.setFullScreenMode(true);
myCanvas.setHeight();


in Canvas class:

public void setHeight()
{
DISP_HEIGHT = getHeight();
yOffset = 13 + ((DISP_HEIGHT-208)/2);
}

Oddly, the function getHeight() still return the 144px of the non fullscreen mode. I need to calculate the yOffset to center the screen content for devices with different screen height (eg. Sony Ericsson 220px).

Is there any possibility to get the real screen height in fullscreen mode? I heard about some kind of hardware profiles, but didn't find any functions which support them.

Thx for your help,

Eric
Reply With Quote

#2 Old 2005-03-30, 14:33

Join Date: Aug 2004
Posts: 33
derdasser
Offline
Registered User
Ok, i guess here is the solution for your problem:

The fullscreen setting takes a while.
therefore calling getHeight() right after it will get the old data.

What you have to do is to implement this method in your Canvas Class:

public void sizeChanged() {
DISP_HEIGHT = getHeight();
yOffset = 13 + ((DISP_HEIGHT-208)/2);
}

because sizeChanged() is automatically called by the Canvas, if something changes about the size.

So just replace your public void setHeight()
with my public void sizeChanged()
and delete your line
myCanvas.setHeight();

Alexander

Sorry for answering that late.
I hope it still helps. ;)
Reply With Quote

#3 Old 2005-03-30, 17:37

Join Date: Jun 2004
Posts: 7
teric
Offline
Registered User
Thanks a lot for your support, I'm gonna try this out.
I'll tell you later, if it worked ;)

EDIT: Just tried, didn't work :(
Apparently the sizeChanged()-function is not called. Any other idea?

Have a nice day,

Eric
Last edited by teric : 2005-03-30 at 18:10.
Reply With Quote

#4 Old 2005-03-30, 19:15

Join Date: Aug 2004
Posts: 33
derdasser
Offline
Registered User
Hehe

I'm sorry.
Here's the real solution:

protected void sizeChanged(int w,int h) {
DISP_HEIGHT = h;
yOffset = 13 + ((DISP_HEIGHT-208)/2);
}

Replace my old sizeChanged with this one above.

Stupid me ;-)

This one will work.

Alexander
Reply With Quote

#5 Old 2005-03-31, 01:32

Join Date: Jun 2004
Posts: 7
teric
Offline
Registered User
Ok, this works on my Nokia 3230, I'm going to test it on some other devices soon. Thanks again for your support :)

As you might have expected, it doesn't work with my emulators ;)

Greetings,

Eric



P.S.: Where did you find this information? I read something about this function, but I didn't find any info about parameters passed.
Reply With Quote

#6 Old 2005-03-31, 03:08

Join Date: Aug 2004
Posts: 33
derdasser
Offline
Registered User
I once had the same problem.
I found the solution in the Canvas Api.
Was a little bit hidden. ;-)
Reply With Quote

#7 Old 2005-07-21, 13:03

Join Date: Jul 2005
Posts: 64
pankaj_hotwani
Offline
Regular Contributor
Here is the solution:

Just after display.setCurrent stop the main thread for about 200 ms by writing the following statement

Thread.sleep(200);

After this you call your setHeight method. Then it will return the height of fullCanvas. Hope this works.....
Reply With Quote

#8 Old 2005-07-23, 15:00

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
I would not recommend using sleep() in this way, as it is highly non-portable. The correct way is to use the sizeChanged() event as Alexander writes.

Alternatively, getHeight() in the paint() method every time it is called.

The problem comes from the fact that the Canvas does not change height immediately, but at some future point. You must wait for an appropriate event (such as sizeChanged() or paint()) before checking getHeight().

Graham.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ