Windows jump animation error

D

Dragonfly

Guest
Hello!

I made a run and jump animation for my sprite in my game using this code
Code:
if (move !=0) image_xscale = move;
if (place_meeting(x,y+1,obj_grass_middle))
{
    if (move !=0) sprite_index = spr_player_run; else sprite_index = spr_player;
}
else
{
    if (vsp < 0) sprite_index = spr_player_jump; else sprite_index = spr_player;
}
The code for the running works but I get this error for the jump code..


Any of you know what I do wrong?

Thank you in advance
 
C

CreatorAtNight

Guest
I think you need to use vspeed instead of vsp. Or you need to declare vsp.

The error you get means that you are refering to a variable that hasn't been declared.
 
D

Dragonfly

Guest
I think you need to use vspeed instead of vsp. Or you need to declare vsp.

The error you get means that you are refering to a variable that hasn't been declared.
Oh okay!

Your error message suggests you haven't set any values to your vsp variable.

Do you have anything in the create event for vsp?

Create Event:
Code:
vsp = 0;
I tried it and it works now, thank you!!
 

Calvert

Member
I tried it and it works now, thank you!!
Any time you use variables in Gamemaker, always make sure you declare the variables first.

It's like if you tell a little kid to fetch you a wrench for the first time. The kids going to come back with an error message, like "What's a wrench?"

First, you've gotta tell your kid what a wrench is, then you can start talking about wrenches so your kid can understand.

That's the mistake you made with Gamemaker when you started telling it about your "vsp" variable. Gamemaker came back with an error message saying "What's a vsp?"

That's why when your object gets created, we tell it what vsp is by assigning it a value.

Good luck on your future programming journey!
 
D

Dragonfly

Guest
Any time you use variables in Gamemaker, always make sure you declare the variables first.

It's like if you tell a little kid to fetch you a wrench for the first time. The kids going to come back with an error message, like "What's a wrench?"

First, you've gotta tell your kid what a wrench is, then you can start talking about wrenches so your kid can understand.

That's the mistake you made with Gamemaker when you started telling it about your "vsp" variable. Gamemaker came back with an error message saying "What's a vsp?"

That's why when your object gets created, we tell it what vsp is by assigning it a value.

Good luck on your future programming journey!
Great explaination, thank you!
 
Top