Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> sprite_index doesn't work, GML problem
sana'a
post Sep 5 2011, 09:56 AM
Post #1



Group Icon

Group: Member
Posts: 2
Type: None
RM Skill: Undisclosed




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.
Go to the top of the page
 
+Quote Post
   
TheBen
post Sep 5 2011, 01:50 PM
Post #2


Intolerable Noob
Group Icon

Group: Revolutionary
Posts: 344
Type: Developer
RM Skill: Beginner




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


__________________________
QUOTE
Great people talk about IDEAS
Average people talk about THINGS
Small people talk about OTHER PEOPLE

- A plaque on a BBQ restaurant in VA
Go to the top of the page
 
+Quote Post
   
sana'a
post Sep 6 2011, 01:53 AM
Post #3



Group Icon

Group: Member
Posts: 2
Type: None
RM Skill: Undisclosed






thanks for help,but it didn't work
any other ideas??
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 12:04 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker