Legacy GM [SOLVED] Sprite Opacity Problem

Hey guys!
Here's another noob question from me:

I have an object, with a sprite that has the image alpha of 80 (in the sprite editor).
The sprite is drawn with 255 though... Like it has the full image alpha...
I didnt change anything in the draw event or so.
can another object affect this one's opacity somehow?

thanks in advance!
 

Neptune

Member
If you don't have any weird blend modes going, then perhaps a different object is changing it by:
Code:
an_object.image_alpha = 1;
Another option would being using draw_sprite_ext -- which allows you to choose the alpha value.
@LucasTheNewbie
On another note, I recognize your avatar -- I just recently downloaded FL Studio; if you have experience with it, do you have any tutorial recommendations for getting started with making video game soundtracks?
 
If you don't have any weird blend modes going, then perhaps a different object is changing it by:
Code:
an_object.image_alpha = 1;
Another option would being using draw_sprite_ext -- which allows you to choose the alpha value.
@LucasTheNewbie
On another note, I recognize your avatar -- I just recently downloaded FL Studio; if you have experience with it, do you have any tutorial recommendations for getting started with making video game soundtracks?
Thanks, this was really helpful. I indeed have am object change its alpha...
I'm going to check it out later.

And about FL Studio: feel free to Inbox me here or email at [email protected]

:)

Thanks for your reply!



EDIT:

actually... When I think about it...
I never had that problem, especially with a fixed sprite, that has a certain opacity. I set the transparency directly in the sprite editor. Does the other object even affect that? Or at least would it be able to affect it?
It's really confusing me, cause I never had that problem.

I'm going to explain you what exactly happens in my game:

1. There are menu buttons, which are drawn rectangles.
2. They are changing it's own image_alpha when hovering with the mouse.
3. I have some other buttons, which are not drawn, but fixed sprites. Even when I set their image_alpha to 0 in the draw event, they are fully drawn.
They do not change their opacity by hovering.

Any clue? I tried a lot of different things, like setting their image_alpha manually and so..
 
Last edited:

Perseus

Not Medusa
Forum Staff
Moderator
@Vether: image_alpha is a multiplier for opacity. If you have set it to 1, opacity of 80 would still be 80 x 1 = 80, not 255. It is not possible to set it to a value larger than 1 or smaller than 0, so the opacity that it could set lies between 0 and 80 (including 0 and 80).

@LucasTheNewbie: For drawn shapes, you need draw_set_alpha, not image_alpha. If image_alpha doesn't change anything upon being set, it is possible that you are using either draw_sprite or draw_sprite_ext to draw the sprite. In case of the former, it doesn't have the alpha attribute and you need to replace it with the latter. In case of the latter, you're probably not setting its alpha argument to image_alpha. A viable solution in either case is to use draw_self instead. Apart from that, we need more relevant information in order to help if the issue persists.
 
@Vether: image_alpha is a multiplier for opacity. If you have set it to 1, opacity of 80 would still be 80 x 1 = 80, not 255. It is not possible to set it to a value larger than 1 or smaller than 0, so the opacity that it could set lies between 0 and 80 (including 0 and 80).

@LucasTheNewbie: For drawn shapes, you need draw_set_alpha, not image_alpha. If image_alpha doesn't change anything upon being set, it is possible that you are using either draw_sprite or draw_sprite_ext to draw the sprite. In case of the former, it doesn't have the alpha attribute and you need to replace it with the latter. In case of the latter, you're probably not setting its alpha argument to image_alpha. A viable solution in either case is to use draw_self instead. Apart from that, we need more relevant information in order to help if the issue persists.
I actually tried both versions, cause I wasnt sure. I have used "draw_self()" too in the draw event.

I don't think it's due to the drawing, but rather something else.
I mean: I created a sprite with the built in sprite editor and drew arectangle. then I changed this sprites opacity using the sprite editor too. i simply made it half transparent.
I never had a problem like this, or that a sprite i drew myself wasnt shown as transparent as i made it.
I suppose it's being layerd multiple times by anything.
so 50% opacity + 50% opacity is 100% opacity as an example.

I didnt do anything different this time, but I can't figure out what it is.


some more information:

  • I used this tutorial for GUI buttons by Heartbeast. (copied it 100% lol)
  • I have three other buttons, which aren't a part of this menu
  • these buttons are simply rectangular sprites, made with the sprite editor and a draw event that displays white text saying "Button Name".
  • I used draw_self() in order to display the sprite first, then the text.
  • these self-made buttons do not have the hover function in it. it's simply clickable rectangles.
Self-made button's draw event:
Code:
draw_self();

draw_set_font(fnt_main);
draw_set_color(c_white);
draw_set_halign(fa_center);
draw_set_valign(fa_center);
draw_text(x,y,"Bild");
Hope you can work with these informations :D
 
Oh my god, mega facepalm!!!

That's truly embarrassing.
It actually really created the sprite twice.
The button is being created as soon, as the user clicks on a certain instance.
The problem was solved by changing the event to "right mouse button released"...

ahem... thanks anyway guys! really appreciate your help! <3
 
Top