Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1412072 Posts in 69447 Topics- by 58483 Members - Latest Member: Exye

June 25, 2024, 03:01:44 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Sprites showing with black backrounds in Game Maker
Pages: [1]
Print
Author Topic: Sprites showing with black backrounds in Game Maker  (Read 5948 times)
Pishtaco
Level 10
*****


View Profile WWW
« on: March 07, 2010, 11:05:23 AM »

This is a problem someone has run into with Stacker:http://forums.tigsource.com/index.php?topic=2455.msg348806#msg348806

I'm sure I've read about something like this happening with other GM games, but I can't remember whether there's a standard straightforward way to fix it or not. My guess about what the problem is, is that it's a sprite with some alpha transparency being drawn onto a surface, and then that surface later being drawn onto the screen; the problem is that the surface isn't coping with the alpha properly.

Any suggestions?
Logged

ChevyRay
Guest
« Reply #1 on: March 07, 2010, 03:59:25 PM »

Argh, yeah, the boulder is a finicky little thing.  I know what's wrong, I just find it hard to test for.

Hey Derek, I don't know if you've fixed the surface transparency issue (black squares around sprites) but here's the fix for it:

Call this code after you've drawn to the surface, before you reset surface target:
Quote
draw_set_blend_mode_ext(bm_src_color,bm_one)
draw_set_color(c_black)
draw_rectangle(0,0,width,height,0)
draw_set_blend_mode(bm_normal)

It's caused by some oddity in the way Game Maker handles transparency in surfaces. What this code does is set the blending mode to write to the alpha channel only then it blanks it out.

EDIT: Oh right, as for getting "Trying to use non-existing surface" errors, you can prevent that by checking surface_exists(surf). If the surface doesn't exist immediately re-create. If that isn't enough to solve the problem loop through that code a few times with 100ms sleep() calls in between to give it some time to clear the VRAM.

Hey, thanks for that, Sean!
Logged
Pishtaco
Level 10
*****


View Profile WWW
« Reply #2 on: March 08, 2010, 02:04:17 PM »

Thanks!
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic