P
philjay
Guest
Hello, im new to the forums, just downloaded gamemaker. I'm having this error message while trying to make animated character movement:
___________________________________________
############################################################################################
ERROR in
action number 1
of Step Event0
for object oPlayer:
Variable oPlayer.localFrame(100009, -2147483648) not set before reading it.
at gml_Script_AnimateSprite (line 5) - image_index = localFrame + (_cDirection * _totalFrames);
############################################################################################
gml_Script_AnimateSprite (line 5)
gml_Object_oPlayer_Step_0 (line 38)
Script: (root)
1.
###
//// update-sprite
function AnimateSprite(){
var _cDirection = round(direction/90);
var _totalFrames = sprite_get_number(sprite_index) / 4;
image_index = localFrame + (_cDirection * _totalFrames);
localFrame += sprite_get_speed(sprite_index) / FRAME_RATE;
//// animation-loop
if (localframe >= _totalFrames)
{
animationEnd = true;
localframe -= _totalFrames;
}else animationEnd = false;
}
###
2. (Step)
###
//// basic-input-commands
keyLeft = keyboard_check(vk_left);
keyRight = keyboard_check(vk_right);
keyUp = keyboard_check(vk_up);
keyDown = keyboard_check(vk_down);
//// other-commands
//// keyActivate = keyboard_check_pressed(vk_space);
//// keyAttack = keyboard_check_pressed(ord("C"));
//// keyItem = keyboard_check_pressed(ord("V"));
//// vector-45-degrees-direction-movement-speed-reduction
//// 0-degrees = Right //// 270-degrees = Down
inputDirection = point_direction(0,0,keyRight-keyLeft,keyDown-keyUp);
inputMagnitude = (keyRight - keyLeft != 0) || (keyDown - keyUp != 0);
//// Player-Movement
hSpeed = lengthdir_x(inputMagnitude * speedWalk, inputDirection);
vSpeed = lengthdir_y(inputMagnitude * speedWalk, inputDirection);
x += hSpeed;
y += vSpeed;
//// Sprite-Update
var _oldSprite = sprite_index;
if (inputMagnitude != 0)
{
direction = inputDirection
sprite_index = spriteRun;
} else sprite_index = spriteIdle;
if (_oldSprite != sprite_index) localFrame = 0;
//// update-image-index
script_execute(AnimateSprite);
###
3. Create
###
/// player move action
image_speed = 0;
hSpeed = 0;
vSpeed = 0;
speedWalk = 3.0;
spriteRun = oPlayerWalk;
spriteIdle = oPlayerSprite;
localframe = 0;
###
___________________________________________
############################################################################################
ERROR in
action number 1
of Step Event0
for object oPlayer:
Variable oPlayer.localFrame(100009, -2147483648) not set before reading it.
at gml_Script_AnimateSprite (line 5) - image_index = localFrame + (_cDirection * _totalFrames);
############################################################################################
gml_Script_AnimateSprite (line 5)
gml_Object_oPlayer_Step_0 (line 38)
Script: (root)
1.
###
//// update-sprite
function AnimateSprite(){
var _cDirection = round(direction/90);
var _totalFrames = sprite_get_number(sprite_index) / 4;
image_index = localFrame + (_cDirection * _totalFrames);
localFrame += sprite_get_speed(sprite_index) / FRAME_RATE;
//// animation-loop
if (localframe >= _totalFrames)
{
animationEnd = true;
localframe -= _totalFrames;
}else animationEnd = false;
}
###
2. (Step)
###
//// basic-input-commands
keyLeft = keyboard_check(vk_left);
keyRight = keyboard_check(vk_right);
keyUp = keyboard_check(vk_up);
keyDown = keyboard_check(vk_down);
//// other-commands
//// keyActivate = keyboard_check_pressed(vk_space);
//// keyAttack = keyboard_check_pressed(ord("C"));
//// keyItem = keyboard_check_pressed(ord("V"));
//// vector-45-degrees-direction-movement-speed-reduction
//// 0-degrees = Right //// 270-degrees = Down
inputDirection = point_direction(0,0,keyRight-keyLeft,keyDown-keyUp);
inputMagnitude = (keyRight - keyLeft != 0) || (keyDown - keyUp != 0);
//// Player-Movement
hSpeed = lengthdir_x(inputMagnitude * speedWalk, inputDirection);
vSpeed = lengthdir_y(inputMagnitude * speedWalk, inputDirection);
x += hSpeed;
y += vSpeed;
//// Sprite-Update
var _oldSprite = sprite_index;
if (inputMagnitude != 0)
{
direction = inputDirection
sprite_index = spriteRun;
} else sprite_index = spriteIdle;
if (_oldSprite != sprite_index) localFrame = 0;
//// update-image-index
script_execute(AnimateSprite);
###
3. Create
###
/// player move action
image_speed = 0;
hSpeed = 0;
vSpeed = 0;
speedWalk = 3.0;
spriteRun = oPlayerWalk;
spriteIdle = oPlayerSprite;
localframe = 0;
###