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
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
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
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
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
Ok, thanks Minion, i didn't realise it had to be assigned immediately.
It is logical, but you need to get used to it :)
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?
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
Its possible it's a bug - it does appear that GRABSPRITE is ignoring the transparency value in all respects.
Any update on TRANSPARENCY not working with GRABSPRITE? :'( It's a very useful feature!
It works for me:
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.
The issue is with PRINT which has white but is ignored by tyhe grabsprite transparency.
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
As far as I can see it works fine - ie only the surrounding black pixels of the font are displayed
[attachment deleted by admin]