Help - Search - Members - Calendar
Full Version: sprite_index doesn't work
RPG RPG Revolution Forums > Game Engines > RPG Maker 2000 / 2003 > General Game Engines Discussion
sana'a
Hi evrybody
i'm new here,and i'm sorry because this is my first post and it's a question happy.gif
but really need help.
I'm working on platform game using animated sprites for jumping,walking and firing.
all sprite changes work just fine but when i'm trying to fire the character doesn't change to shooting sprite.

and this is the code in step event


CODE
if keyboard_check(keyLeft)
{LR=0
  image_speed = 0.5
  if (place_free (x - moveSpeed,y)) //check if a wall is to the right
  {
    x -= moveSpeed
  }
  if (vspeed == 0) //check if player is on the ground
  {
    sprite_index = spr_walkingL;
  }
//flip sprite image to face left
}

if keyboard_check(keyRight)
{LR=1
  image_speed = 0.5
  if (place_free (x + moveSpeed,y)) //check if a wall is to the left
  {
    x += moveSpeed
  }
  if (vspeed == 0) //check if player is on the ground
  {
    sprite_index = spr_walkingR;
  }

}

if (!place_free(x,y+1)and keyboard_check(vk_up))
{
if LR=0
sprite_index=spr_jumpL;
else
sprite_index=spr_jumpR;
vspeed=-12;}
//SHOOTING---------------------------------------------------------------------------
if (keyboard_check(vk_space) and !keyboard_check(vk_right) and !keyboard_check(vk_left) and !keyboard_check(vk_up) and gunReady=1)
{image_speed=0;
if LR=0
{
sprite_index=spr_fireL;
instance_create(x,y,obj_bulletL);
}
else if LR=1
{
sprite_index=spr_fireR;
instance_create(x,y,obj_bulletR);
}
gunReady=0;
alarm[0]=10;
}


if (!keyboard_check(vk_up) and !keyboard_check(vk_right) and !keyboard_check(vk_left))

{
  image_speed=0;
  if LR=0
{
  sprite_index =spr_stopL;
}
if LR=1
{
sprite_index = spr_stopR;
}
}


thanks in advanced.
TheBen
You have the animation set to change only when gunReady=1. What this means is that the object uses the shooting animation ONLY when the gun is ready to fire. You may want to include an if clause specifically for the shooting animation, e.g.
CODE
if (keyboard_check(vk_space) and !keyboard_check(vk_right) and !keyboard_check(vk_left) and !keyboard_check(vk_up)) {
   image_speed=0;
   if LR=0 {
      sprite_index = spr_fireL;
   } else if LR=1 {
      sprite_index = spr_fireR;
   }
   if gunready=1 {
      instance_create(x, y, obj_bulletL);
      gunReady=0;
      alarm[0]=10;
   }
}

I'm not sure if that would work in your game, exactly, but the concept may be useful to you.
I hope this helps. happy.gif
sana'a


thanks for help,but it didn't work
any other ideas??
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.