GLBasic forum

Main forum => GLBasic - en => Topic started by: okee on 2012-Mar-11

Title: Grabsprite problem
Post by: okee on 2012-Mar-11
Basically i want to grab the left half of the screen and the right half of the screen
into 2 separate images to do a simple transition.

When i do

Code (glbasic) Select
GRABSPRITE Grab1,0,0,400,600 // grab left side of screen
GRABSPRITE Grab2,400,0,400,600 // grab right side of screen


I end up with 2 images of the right side of the screen
if i do
Code (glbasic) Select

GRABSPRITE Grab2,400,0,400,600 // grab right side of screen
GRABSPRITE Grab1,0,0,400,600 // grab left side of screen


I end up with 2 images of the left side of the screen.
Is it not possible to do 2 GrabSprite together ?


Full code
Code (glbasic) Select
SETCURRENTDIR("Media") // go to media files
SETSCREEN 800,600,1
SETTRANSPARENCY RGB(255,0,255)
GLOBAL Back = GENSPRITE(); LOADSPRITE "back.png",Back
GLOBAL Grab1 = GENSPRITE();
GLOBAL Grab2 = GENSPRITE();

DRAWSPRITE Back,0,0

GRABSPRITE Grab1,0,0,400,600
GRABSPRITE Grab2,400,0,400,600

WHILE KEY(1) <> 1

DRAWSPRITE Grab1,0,0
DRAWSPRITE Grab2,400,0

SHOWSCREEN
WEND
Title: Re: Grabsprite problem
Post by: Minion on 2012-Mar-11
you set grab1 with gensprite, then you set grab2 to gensprite as well, both will be the same. You will need to use gensprite, then grab the sprite, then use gensprite again to get a new value. gensprite will find the first available slot for a sprite, but as you have not filled that slot with grab1 before you set grab2 then they will both be the same.

Hope that helps
Title: Re: Grabsprite problem
Post by: okee on 2012-Mar-11
Ok, thanks Minion, i didn't realise it had to be assigned immediately.
Title: Re: Grabsprite problem
Post by: MrTAToad on 2012-Mar-12
It is logical, but you need to get used to it :)
Title: Re: Grabsprite problem
Post by: S.O.P.M. on 2012-Mar-12
This is a good topic because I also have a problem with GRABSPRITE. With SETTRANSPARENCY you can set the transparent color for GRABSPRITE too, right?

I set the color to white, draw a white rectangle and grab it, the sprite should be invisible - but it's not! Why?

Code (glbasic) Select
SETSCREEN 800, 480, 0

SETTRANSPARENCY 0xffffff

WHILE KEY(1) = 0
DRAWRECT 100, 100, 100, 100, 0xffffff
GRABSPRITE 0, 100, 100, 100, 100
ROTOSPRITE 0, 300, 100, 45
SHOWSCREEN
WEND
Title: Re: Grabsprite problem
Post by: MrTAToad on 2012-Mar-12
Its possible it's a bug - it does appear that GRABSPRITE is ignoring the transparency value in all respects.
Title: Re: Grabsprite problem
Post by: matchy on 2012-May-09
Any update on TRANSPARENCY not working with GRABSPRITE?  :'( It's a very useful feature!
Title: Re: Grabsprite problem
Post by: Kitty Hello on 2012-May-09
It works for me:
Code (glbasic) Select


LOCAL trans% = 0xffffff
WHILE 1
SETTRANSPARENCY trans%
DRAWRECT 0,0,100,100,trans%
DRAWRECT 20,20,60,60,0x00ffff
DRAWRECT 40,40,20,20,trans%
GRABSPRITE 0,0,0, 100,100

ROTOSPRITE 0, 200, 100, GETTIMERALL()*0.10

SHOWSCREEN
WEND


Check your GRABSPRITE coords.
Title: Re: Grabsprite problem
Post by: matchy on 2012-May-09
The issue is with PRINT which has white but is ignored by tyhe grabsprite transparency.

Code (glbasic) Select

LOCAL trans% = 0x000000 // keep white
LOCAL file_name$ = "Media/fonts/font1.png"

SMOOTHSHADING FALSE
SETTRANSPARENCY trans%
LOADFONT file_name$, 0
SETFONT 0

WHILE 1
SMOOTHSHADING FALSE
trans% = 0xffffff
SETTRANSPARENCY trans%
DRAWRECT 0,0,100,100,trans%
PRINT "ABC", 10, 10

DRAWRECT 20,20,60,60,0x00ffff
DRAWRECT 40,40,20,20,trans%
GRABSPRITE 0,0,0, 100,100

CLEARSCREEN RGB(255, 0, 0)
ROTOSPRITE 0, 200, 100, GETTIMERALL()*0.10

SHOWSCREEN
WEND
Title: Re: Grabsprite problem
Post by: MrTAToad on 2012-May-09
As far as I can see it works fine - ie only the surrounding black pixels of the font are displayed

[attachment deleted by admin]