Author Topic: Grabsprite problem  (Read 2610 times)

Offline okee

  • Dr. Type
  • ****
  • Posts: 324
    • View Profile
Grabsprite problem
« 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
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

Offline Minion

  • Mr. Polyvector
  • ***
  • Posts: 229
    • View Profile
Re: Grabsprite problem
« Reply #1 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

Offline okee

  • Dr. Type
  • ****
  • Posts: 324
    • View Profile
Re: Grabsprite problem
« Reply #2 on: 2012-Mar-11 »
Ok, thanks Minion, i didn't realise it had to be assigned immediately.
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

MrTAToad

  • Guest
Re: Grabsprite problem
« Reply #3 on: 2012-Mar-12 »
It is logical, but you need to get used to it :)

Offline S.O.P.M.

  • Prof. Inline
  • *****
  • Posts: 529
    • View Profile
Re: Grabsprite problem
« Reply #4 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
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

MrTAToad

  • Guest
Re: Grabsprite problem
« Reply #5 on: 2012-Mar-12 »
Its possible it's a bug - it does appear that GRABSPRITE is ignoring the transparency value in all respects.

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1542
    • View Profile
Re: Grabsprite problem
« Reply #6 on: 2012-May-09 »
Any update on TRANSPARENCY not working with GRABSPRITE?  :'( It's a very useful feature!

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10708
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Grabsprite problem
« Reply #7 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.

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1542
    • View Profile
Re: Grabsprite problem
« Reply #8 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
 

MrTAToad

  • Guest
Re: Grabsprite problem
« Reply #9 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]