WebOS createscreen problem

Previous topic - Next topic

Crivens

I've created a function that creates a word wrapped sprite based on screen resolution basically so a standard font can be used (resizing a font doesn't work 100% on my screen scaling code).

This works fine for PC and iOS but on WebOS it is having problems. If I use the function twice (two different sets of text) then neither sprite will show anything. Once and it works fine. If I pass in a screen number for createscreen and make the second use of the function a different createscreen number then it also works fine on WebOS. But why?

Here is the function:-
Code (glbasic) Select
FUNCTION printsprite:pstext$,psfont%
LOCAL sentence$[],word$,fontw%,fonth%
SETFONT psfont
GETFONTSIZE fontw,fonth
pstext$=pstext$+" "
WHILE pstext$<>""
word$=pstext$
WHILE LEN(word$,1)>targetx OR RIGHT$(word$,1)<>" "
word$=LEFT$(word$,LEN(word$)-1)
WEND
DIMPUSH sentence$[],TRIM$(word$)
pstext$=LTRIM$(MID$(pstext$,LEN(word$)))
WEND
LOCAL pssprite%=GENSPRITE()
CREATESCREEN 9,pssprite,targetx,fonth*LEN(sentence$)
USESCREEN 9
LOCAL itemno=0
FOREACH item$ IN sentence$[]
PRINT item$,(targetx/2)-(LEN(item$,1)/2),fonth*itemno,1
INC itemno
NEXT
USESCREEN -1
RETURN pssprite
ENDFUNCTION


Note that this is in a different file to the main code being called from a function. Also in another file to the main code I use a similar technique and that works with no problem in WebOS. This though works with the createsreen one after another with no function to make things easier. Here is the code from that function:-
Code (glbasic) Select
LOCAL shoptext%,shopchar$,shoptext2%,shopchar2$,shoptext3%,shopchar3$,shoptext4%,shopchar4$
IF info=0
shoptext%=GENSPRITE()
shopchar$="Accessing Shop"
CREATESCREEN 9,shoptext,targetx,shopfonth
USESCREEN 9
SETFONT shoptitlefont
PRINT shopchar$,0,0,1
USESCREEN -1
shoptext2%=GENSPRITE()
shopchar2$="Please wait..."
CREATESCREEN 9,shoptext2,targetx,shopfonth
USESCREEN 9
SETFONT shopfont
PRINT shopchar2$,0,0,1
USESCREEN -1
shoptext3%=GENSPRITE()
shopchar3$="Accessing Web"
CREATESCREEN 9,shoptext3,targetx,shopfonth
USESCREEN 9
SETFONT shoptitlefont
PRINT shopchar3$,0,0,1
USESCREEN -1
shoptext4%=GENSPRITE()
shopchar4$="Processing Info"
CREATESCREEN 9,shoptext4,targetx,shopfonth
USESCREEN 9
SETFONT shoptitlefont
PRINT shopchar4$,0,0,1
USESCREEN -1
This works perfectly on WebOS with all sprites showing fine.

Considering this all works perfectly on iOS and PC with multiple resolutions it is annoying the hell out of me. Can you see if there is a problem with the WebOS implementation Gernot?

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Kitty Hello

it's a webos bug!
You can't draw / reuse the same offscreen in one showscreen loop with different contents. I can't find a way to make it work.
Use a separeate screen if possible.

Crivens

Hmm. Ok. So how come my second example works? It uses screen 9 for about 4 different sprites. The only major difference is my first example uses a separate function to produce the sprites rather than just repeating the code one after the other like I have done in the second example.

But basically you are saying if WebOS I should use a showscreen at the end of the printsprite function or just cycle through the screen numbers?

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Kitty Hello

after a usescreen -1 you can't reuse the same screen again until you have a showscreen. Very silly.

Crivens

But if you look at my second code example I do createscreen 9, usescreen -1 about 4 times in a row with different sprites and without a showscreen and all the sprites are fine. My first example is essentially the same thing except it used a function per sprite. Confusing...

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Kitty Hello

totally. If you manage to find a function that causes it, I might have a look and see if I can fix it.

Crivens

QuoteIf you manage to find a function that causes it, I might have a look and see if I can fix it
My first function causes it. Call it twice in a row without a showscreen and neither sprite will have anything in it (size is correct though). My second code example pretty much does the same thing but not in a separate function and it works fine.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Crivens

Ok the idea of using a showscreen between createscreens doesn't seem to make any difference. Using a different usescreen value though works. I used a global variable and then toggled the screen with it for WebOS:-
Code (glbasic) Select
FUNCTION printsprite:pstext$,psfont%
LOCAL sentence$[],word$,fontw%,fonth%
SETFONT psfont
GETFONTSIZE fontw,fonth
pstext$=pstext$+" "
WHILE pstext$<>""
word$=pstext$
WHILE LEN(word$,1)>targetx OR RIGHT$(word$,1)<>" "
word$=LEFT$(word$,LEN(word$)-1)
WEND
DIMPUSH sentence$[],TRIM$(word$)
pstext$=LTRIM$(MID$(pstext$,LEN(word$)))
WEND
LOCAL pssprite%=GENSPRITE()
LOCAL myscreen%=9
?IFDEF WEBOS
webosscr=1-webosscr
INC myscreen,webosscr
?ENDIF
CREATESCREEN myscreen,pssprite,targetx,fonth*LEN(sentence$)
USESCREEN myscreen
LOCAL itemno=0
FOREACH item$ IN sentence$[]
PRINT item$,(targetx/2)-(LEN(item$,1)/2),fonth*itemno,1
INC itemno
NEXT
USESCREEN -1
RETURN pssprite
ENDFUNCTION


Ok, so that workaround worked but why didn't the showscreen after the usescreen -1 in the function above work?

Also how come my 2nd example code, that doesn't use a seperate function, work fine without a showscreen or even changing the usescreen value (it just uses 9)? It's like not so much that the usescreen has to be a different value but that it can't have the same value in the same code area (ie. the separate area). I mean look at the other code which works fine:-
Code (glbasic) Select
shoptext%=GENSPRITE()
shopchar$="Accessing Shop"
CREATESCREEN 9,shoptext,targetx,shopfonth
USESCREEN 9
SETFONT shoptitlefont
PRINT shopchar$,0,0,1
USESCREEN -1
shoptext2%=GENSPRITE()
shopchar2$="Please wait..."
CREATESCREEN 9,shoptext2,targetx,shopfonth
USESCREEN 9
SETFONT shopfont
PRINT shopchar2$,0,0,1
USESCREEN -1
shoptext3%=GENSPRITE()
shopchar3$="Accessing Web"
CREATESCREEN 9,shoptext3,targetx,shopfonth
USESCREEN 9
SETFONT shoptitlefont
PRINT shopchar3$,0,0,1
USESCREEN -1
shoptext4%=GENSPRITE()
shopchar4$="Processing Info"
CREATESCREEN 9,shoptext4,targetx,shopfonth
USESCREEN 9
SETFONT shoptitlefont
PRINT shopchar4$,0,0,1
USESCREEN -1
CLEARSCREEN
STRETCHSPRITE shoptext,x*((targetx/2)-(LEN(shopchar$,1)/2)),y*((targety/2)-(shopfonth/2)-200),x*targetx,y*shopfonth
STRETCHSPRITE shoptext2,x*((targetx/2)-(LEN(shopchar2$,1)/2)),y*((targety/2)+(shopfonth/2)-200),x*targetx,y*shopfonth
STRETCHSPRITE shoptext3,x*((targetx/2)-(LEN(shopchar3$,1)/2)),y*((targety/2)+(shopfonth*2)),x*targetx,y*shopfonth
SHOWSCREEN

Note it has no showscreen until right at the end and all of them use createscreen with number 9. Works fine. Plus I have a loop a bit later that runs though an array and creates a load of sprites in the same manner all using screen number 9, and without a showscreen, and that works fine too. It's like I use the same function to do each and every sprite, rather than one function to do the lot (which works although note the drawing of the sprites is also in the same function interestingly), and it will fail.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.