Jump to content


Photo

Change Sprite Command In Gml


  • Please log in to reply
12 replies to this topic

#1 GossamerS

GossamerS

    GMC Member

  • New Member
  • 19 posts

Posted 26 February 2009 - 04:50 AM

What is the code for the Change Sprite command (D&D) into GML. I searched the game maker help and the forums here. I guess its called something different.

example: Right now I have the D&D command change sprite with the following properties: Sprite: spr_idle subimage: 0 and speed: 0

I'd like to know what the command is so I can do this in GML instead. Thanks for the help!

Edited by GossamerS, 26 February 2009 - 04:53 AM.

  • 0

#2 Meta Black Yoshi

Meta Black Yoshi

    GMC Member

  • GMC Member
  • 1735 posts
  • Version:Unknown

Posted 26 February 2009 - 04:57 AM

sprite_index=spr_idle;
image_index=0;
image_speed=0;
  • 0

#3 GossamerS

GossamerS

    GMC Member

  • New Member
  • 19 posts

Posted 26 February 2009 - 04:58 AM

thank you very much for the fast response!
  • 0

#4 Meta Black Yoshi

Meta Black Yoshi

    GMC Member

  • GMC Member
  • 1735 posts
  • Version:Unknown

Posted 26 February 2009 - 05:00 AM

No problem. :whistle:
  • 0

#5 GossamerS

GossamerS

    GMC Member

  • New Member
  • 19 posts

Posted 26 February 2009 - 05:09 AM

Actually a new question:

sprite_index=spr_Walking;
image_index=0;
image_speed=10;

Something in here is causing the sprite spr_Walking to not animate properly. I've tried image_index=0; and image_index=0-5; It only animates the 2nd frame.
  • 0

#6 Avelex

Avelex

    GMC Member

  • New Member
  • 27 posts

Posted 26 February 2009 - 05:12 AM

I had that problem too, its your image_speed.
I'm not sure why, but image_speed uses different values then the ones in the gm sprite editor.
Try doing .10, it won't be exactly your speed so you will have to play around with it.
  • 0

#7 Meta Black Yoshi

Meta Black Yoshi

    GMC Member

  • GMC Member
  • 1735 posts
  • Version:Unknown

Posted 26 February 2009 - 05:14 AM

Ya, that speed does seem kind of high. Also, don't use a negative value for image_index.
edit: BTW, default speed is 1.

Edited by Meta Black Yoshi, 26 February 2009 - 05:15 AM.

  • 0

#8 GossamerS

GossamerS

    GMC Member

  • New Member
  • 19 posts

Posted 26 February 2009 - 06:23 AM

I tried image speed 1 and its still screwing up... want me to post the gmk file?
  • 0

#9 Meta Black Yoshi

Meta Black Yoshi

    GMC Member

  • GMC Member
  • 1735 posts
  • Version:Unknown

Posted 26 February 2009 - 06:40 AM

image_index=0;

Are you resetting the image index every step or something? Every time you put this code the sprite will be reset to the first image. So don't put this in the step event.
  • 0

#10 sheep

sheep

    GMC Member

  • New Member
  • 186 posts

Posted 26 February 2009 - 06:44 AM

try:

var _speed, _val;
_speed = 10;
_val = (_speed/30);
image_speed = _val;

Then just make _speed bigger or smaller depending on if you want the sprite to go faster or slower respectively.
  • 0

#11 SP)iNsomnia

SP)iNsomnia

    GMC Member

  • GMC Member
  • 588 posts
  • Version:Unknown

Posted 26 February 2009 - 01:36 PM

try:

var _speed, _val;
_speed = 10;
_val = (_speed/30);
image_speed = _val;

Then just make _speed bigger or smaller depending on if you want the sprite to go faster or slower respectively.



Lol...
Maybe just use image_speed=0.3
:D
  • 0

#12 sheep

sheep

    GMC Member

  • New Member
  • 186 posts

Posted 26 February 2009 - 01:50 PM

try:

var _speed, _val;
_speed = 10;
_val = (_speed/30);
image_speed = _val;

Then just make _speed bigger or smaller depending on if you want the sprite to go faster or slower respectively.



Lol...
Maybe just use image_speed=0.3
:snitch:


Well I was trying a different way to get through to him, :)
  • 0

#13 GossamerS

GossamerS

    GMC Member

  • New Member
  • 19 posts

Posted 26 February 2009 - 04:55 PM

Am I supposed to have the code in a step event?

I currently have it in keypad right. I'm new to gamemaker, sorry:

if player_selected = 1
{
	motion_set(0,2)
	sprite_index=spr_Walking;
	image_index=0;
	image_speed=1; 
}

else
{
	exit
}

I'd actually like to fully translate everything into pure code, I'm not sure how to do it in gamemaker.

I'm doing C++ in university right now so I prefer to have all my code in files rather than objects :D



EDIT: I figured it out I believe

if keyboard_check_pressed(vk_right)
{
	if player_selected = 1
	{
		motion_set(0,2)
		sprite_index=spr_Walking;
		image_index=0;
		image_speed=1; 
	}

	else
	{
		exit
	}
}

In a step event works!


Thank you everybody, I shall be asking more questions later on!

Edited by GossamerS, 26 February 2009 - 04:59 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users