iphone grab sprite

Previous topic - Next topic

djtoon

hi :)
any ideas why grab sprite on a wight png on the iphone turns out blank?



Kitty Hello

no. But Grabsprite _might_ not be working on iOS. I'm almost certain that it does, though.

Can you try CREATESCREEN instead, or do you really rely on Grabsprite? If so, make a small sample project that illustrates the error.

Crivens

It definitely works because that is what I use in my app to break a picture into multiple sprites (tile slider game).

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

djtoon

it works but :

i load 4 images with wight background aand grab sprite them

1 works ok
the second the wight is transperent
and the third and fourth are ok too

weird.
the images all have 255,255,255 background i chk'd in photoshop


Kitty Hello

Before you draw to the back-buffer, draw a rectangle with a solid colour to set/clear the alpha values. (Or call CLEARSCREEN with the colour you want).
Also call SETTRANSPARENCY before the drawing to be sure you don't draw transparent if you don't want it.

djtoon

well dosent work :(
here is my function




FUNCTION loadpages:pageN

CLEARSCREEN RGB(255,255,255)

LOADSPRITE "Media/p"+pageN+".bmp",0

LOCAL s=pageN+1
LOADSPRITE "Media/p"+s+".bmp",3

LOCAL s=pageN-1
LOADSPRITE "Media/p"+s+".bmp",4


DRAWRECT 0,0,sw,sh,RGB(255,255,255)
STRETCHSPRITE 4, 240, 0, -480, 320
GRABSPRITE 1,0,0,480,320



DRAWRECT 0,0,sw,sh,RGB(0,255,0)
DRAWSPRITE 3,0,0

GRABSPRITE 2,240,0,240,320

ENDFUNCTION

Kitty Hello

I'm not sure if I understand your code properly.

See this - and check your STRETCHSPRITE and GRABSPRITE rectangle parameters.

Code (glbasic) Select


SYSTEMPOINTER TRUE

// Make 0-5 images
CREATESCREEN 0,77, 64,64
FOR i=0 TO 5
USESCREEN 0
DRAWRECT 0,0,64,64,0xffffff
PRINT i, 10,10
USESCREEN -1
SAVESPRITE "Media/p"+i+".bmp", 77
NEXT


// Load and display them
loadpages(2)

CLEARSCREEN 0

FOR j=0 TO 4
PRINT "SpID:" +j, j*70,0
VIEWPORT j*70,33,64,64
DRAWSPRITE j, 0, 0
VIEWPORT 0,0,0,0
NEXT
SHOWSCREEN
MOUSEWAIT






FUNCTION loadpages:pageN
LOCAL sw%, sh%
GETSCREENSIZE sw, sh


CLEARSCREEN RGB(255,255,255) // makes white transparent

LOADSPRITE "Media/p"+pageN+".bmp",0 // 0=oiriginal

LOCAL s=pageN+1
LOADSPRITE "Media/p"+s+".bmp",3     // 3=next

LOCAL s=pageN-1
LOADSPRITE "Media/p"+s+".bmp",4     // 4=previous


DRAWRECT 0,0,sw,sh,RGB(255,255,255) // draw transparent white rect -> won't draw anything
STRETCHSPRITE 4, 64, 0, -64, 64
GRABSPRITE 1,0,0,480,320            // 1=mirrored previous(4)



DRAWRECT 0,0,sw,sh,RGB(0,255,0)
DRAWSPRITE 3,0,0

GRABSPRITE 2,0,0,64,64          // 2=next on green bkgnd

ENDFUNCTION


Should output:
[2] [1(flipped)] [3] [3] [1]

djtoon

does create screen work on iphone?

Slydog

Just a long shot, I never tried your code, but you have the 's' variable being declared twice:
Code (glbasic) Select
LOCAL s=pageN+1
LOADSPRITE "Media/p"+s+".bmp",3

LOCAL s=pageN-1            // 2nd time, remove 'LOCAL'
LOADSPRITE "Media/p"+s+".bmp",4


Or remove it all together and try this instead:
Code (glbasic) Select
LOADSPRITE "Media/p" + (pageN+1) + ".bmp",3
LOADSPRITE "Media/p" + (pageN-1) + ".bmp",4


Also, just to be safe, I'd declare the 'pageN' float as integer, using 'FUNCTION loadpages:pageN%'.
Just in case a rouge decimal rounding causes a weird filename.  (just being cautious)
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Kitty Hello

createscreen also works, yes.