• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

image_xscale not working for jump-through platform

L

Luka Radulovic

Guest
I have this line that should change the xscale of the object:
GML:
if (hsp != 0) image_xscale = sign(hsp);
When I use it, nothing happens. So after shifting the location of the code in Step, everything remained the same.
Eventually I just wanted to try out how image_xscale works so I put in this line:
Code:
image_xscale = -1;
The object remains its sprite from the Sprites folder. Nothing still changed.

Here's the full script of the object below.
Create Event:
Code:
sprite_index = -1;
Step Event:
Code:
mask_index = sHorizontalFloater;

hspd = dir * movespeed;

//counting until direction change
// float for 100 frames
if (amount_floated >= total_flying) {
    dir *= -1;
    amount_floated = 0;
}
amount_floated++;


x += hspd;

//masks, and hsp_carry
if (instance_exists(oPlayer)) {
    if (round(oPlayer.y + (oPlayer.sprite_height/2)) > y) || (oPlayer.key_down) {
        mask_index = -1;
    } else {
        mask_index = sHorizontalFloater;  
        if (place_meeting(x, y-1, oPlayer)) oPlayer.hsp_carry = hspd;
    }
}

//animation
// Changing the direction of sprite
if (hspd != 0) image_xscale = sign(hspd);
Draw Step:
Code:
draw_sprite(sHorizontalFloater, 0, x, y);
Last pieces of information: The variables are set in the Variable Definitions section of the object. Its parent is oWall that is an object which does nothing, besides stop play from moving into it.
 
Last edited by a moderator:

Nocturne

Friendly Tyrant
Forum Staff
Admin
draw_sprite() does what it says... it simply draws a sprite and nothing else... if you want to pick up on any of the instance transforms, like image_blend, image_xscale, etc... then you need to either use draw_self() or draw_sprite_ext().

 
L

Luka Radulovic

Guest
draw_sprite() does what it says... it simply draws a sprite and nothing else... if you want to pick up on any of the instance transforms, like image_blend, image_xscale, etc... then you need to either use draw_self() or draw_sprite_ext().

When I put draw_self() instead of the line in Draw Event, I get this error message:
GML:
Trying to draw non-existing sprite.
 at gml_Object_oVerticalFloater_Draw_0 (line 5) - draw_self();
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_oVerticalFloater_Draw_0 (line 5)
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Because you don't have a sprite assigned to the instance. Did you even bother to read the links I supplied...?

draw_self() said:
NOTE: If the instance has no sprite assigned to it, this function will throw an error!
 
L

Luka Radulovic

Guest
I've figured it out in the meantime. Thanks for your advice anyway.
 
Top