Draw GUI scaling

Hi all, I have experienced a number of issues when it comes to drawing graphics to the HUD. The current issue I am facing is a simple sprite scaling issue. For example when I collect a gem I would like my HUD gem to scale up slightly and then back down. I seem to be having problems with it. Am I approaching this in the wrong way? In my game I see no scaling, I apologise once again I am a noob but trying my best to find my feet.
Thanks in advance, code below.

GML:
    if (gemCollected == true)
    {
        gemSize += 0.2;
    }   
    if gemSize >= 1.2
    {
        gemSize -= 0.2;
        if gemSize <= 1
        {
            gemSize = 1;
        }
    }
 

Nidoking

Member
You didn't post any code that changes how the sprite is drawn based on the variable. gemSize is not a Game Maker built-in variable, so it's just a number. If you want to do something with it, you have to actually do it.
 
You didn't post any code that changes how the sprite is drawn based on the variable. gemSize is not a Game Maker built-in variable, so it's just a number. If you want to do something with it, you have to actually do it.
Yes I should have said, in the create event gemSize = 1.

What I am trying to do is have a Hud element pulse or (grow then shrink back to 1)

so..

if (gemCollected == true)

grow to 1.2 then shrink to 1
 

Nidoking

Member
Right... and amountThatThisVariableMattersToGameMaker = 0. You can make up all the random variables you want, but if you want Game Maker to DO something (draw the sprite at a different size), you need to TELL it to do that. You have posted no draw code in this thread at all. Where are you telling Game Maker that you want it to use the value of a variable to determine how to draw a sprite? I suggest that the answer is that you are not, and that the solution to your problem is to add that.
 

Mk.2

Member
Also, gemSize starts at 1, increases by 0.2, checks if it's equal to 1.2 or greater (which it now is), then immediately decreases it by 0.2 so that it's 1 again. So even if this variable is being used to scale the sprite in the draw event, it's going to have a value of 1.
 
Right... and amountThatThisVariableMattersToGameMaker = 0. You can make up all the random variables you want, but if you want Game Maker to DO something (draw the sprite at a different size), you need to TELL it to do that. You have posted no draw code in this thread at all. Where are you telling Game Maker that you want it to use the value of a variable to determine how to draw a sprite? I suggest that the answer is that you are not, and that the solution to your problem is to add that.
Double apologies, in my Draw GUI event I have image_xscale and image_yscale set to the variable gemSize.
Anyway Ignoring that last issue, do you know is there an issue using image_xscale and image_yscale on the Draw GUI even? I mean that it just doesn't work?
 

Nidoking

Member
It would probably be a good idea to post the Draw GUI event code, since you still haven't done that. The above statement still doesn't demonstrate that you're USING the image_xscale and image_yscale variables when you draw the sprite.
 
Thanks for the help ok so in my Draw GUI I have this code currently, I removed the variable for now.

GML:
    draw_sprite(sGemHUD,image_index,60,60);
    image_speed = 0.1;
    image_xscale = 1;
    image_yscale = 1;
When I change the image scale to 2 or 10 even, it does nothing. Have I been ultra stupid and missed something?
 
D

Deleted member 13992

Guest
Does this do anything?

GML:
    image_speed = 0.1;
    image_xscale = 2;
    image_yscale = 2;
    draw_sprite(sGemHUD,image_index,60,60);
Code order is extremely important. Not much point in instructing the sprite to draw differently after you've drawn it.

Depending on what's in the step event, this may or may not change anything. Anything in the step event?
 
Does this do anything?

GML:
    image_speed = 0.1;
    image_xscale = 2;
    image_yscale = 2;
    draw_sprite(sGemHUD,image_index,60,60);
Code order is extremely important. Not much point in instructing the sprite to draw differently after you've drawn it.

Depending on what's in the step event, this may or may not change anything. Anything in the step event?
Hi thanks for your help, that logic makes a lot of sense. No there is nothing in the step event. It just stays the same, no difference in scale.
 

Nidoking

Member
draw_sprite(sGemHUD,image_index,60,60);
This is exactly what I've been telling you. Nowhere, regardless of the order in which you do the things you're doing, are you ever telling it to draw the sprite using the scaling factor you have defined. The image_xscale and image_yscale variables only affect calls to draw_self implicitly. There is nothing in your game that ever tells it to draw this sprite at anything other than its original scale. If you want to draw the sprite at a different size, you must either set all of the necessary parameters and call draw_self, OR call one of the draw functions that includes scaling and pass the necessary values in.

The game only ever does exactly what you tell it to do.
 
D

Deleted member 13992

Guest
I never use draw_sprite, so I didn't even think to comment. But yeah, if you're scaling image_xscale, you need to draw the sprite with a drawing function that supports this parameter. As Nidoking states, gamemaker will only do what you tell it to do.

Use draw_sprite_ext.


GML:
draw_sprite_ext(sGemHUD, image_index, 60, 60, image_xscale, image_yscale, image_angle, image_blend, image_alpha);
 
I never use draw_sprite, so I didn't even think to comment. But yeah, if you're scaling image_xscale, you need to draw the sprite with a drawing function that supports this parameter. As Nidoking states, gamemaker will only do what you tell it to do.

Use draw_sprite_ext.


GML:
draw_sprite_ext(sGemHUD, image_index, 60, 60, image_xscale, image_yscale, image_angle, image_blend, image_alpha);
Wonderful! Thankyou so much for helping this noob out and I highly appreciate the code reference. I have never used draw_sprite_ext before, I didn't know it existed. Problem solved
 
D

Deleted member 13992

Guest
Wonderful! Thankyou so much for helping this noob out and I highly appreciate the code reference. I have never used draw_sprite_ext before, I didn't know it existed. Problem solved
I was reminded of it as well. I had completely forgotten draw_sprite doesn't apply transforms and blending, because I only ever use draw_sprite_ext or the other more complex drawing functions.
 
I was reminded of it as well. I had completely forgotten draw_sprite doesn't apply transforms and blending, because I only ever use draw_sprite_ext or the other more complex drawing functions.
I'm actually going to go back and change a few other things now that I had to settle on work arounds for. This seriously has been a massive help! Thanks again
 
Top