Jump to content


Photo

Sprite Animation


  • Please log in to reply
10 replies to this topic

#1 RedbacK

RedbacK

    GMC Member

  • New Member
  • 63 posts
  • Version:Unknown

Posted 23 April 2012 - 10:21 AM

Hi guys.

In my game, when vitality <1 the sprite changes to a spinning shrinking sprite that is supposed to reach a certain image number then destroy.

This works alot of the time but often the sprite will go through the index twice b4 destroying itself.

Has anone else had this problem?
any help would be appreciated.
  • 0

#2 TerraFriedSheep

TerraFriedSheep

    GMC Member

  • GMC Member
  • 3053 posts
  • Version:GM:Studio

Posted 23 April 2012 - 10:51 AM

Hi guys.

In my game, when vitality <1 the sprite changes to a spinning shrinking sprite that is supposed to reach a certain image number then destroy.

This works alot of the time but often the sprite will go through the index twice b4 destroying itself.

Has anone else had this problem?
any help would be appreciated.


What do you have the image_speed set as? If you have a number greater than 1, the image_index may skip certain sub images and hence it may take two animation cycles to actually equal the image_index number that you want to destroy on.

Edit: One to many _'s.

Edited by Soulsnatcher, 23 April 2012 - 10:51 AM.

  • 0

#3 RedbacK

RedbacK

    GMC Member

  • New Member
  • 63 posts
  • Version:Unknown

Posted 24 April 2012 - 05:59 AM

i have image rotate and shrink 72 frames
speed is .25
destroy > 68 ( i tried diff index numbers)

so .25 should reach an integer every 4th step so any whole number should work right?

when prob does occur,it will go through index very quickly 1st time, then slowly the second time

Edited by RedbacK, 24 April 2012 - 06:01 AM.

  • 0

#4 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 24 April 2012 - 06:57 AM

i have image rotate and shrink 72 frames
speed is .25
destroy > 68 ( i tried diff index numbers)

so .25 should reach an integer every 4th step so any whole number should work right?

when prob does occur,it will go through index very quickly 1st time, then slowly the second time

In the STEP event, you can try if image_index > 71 instance_destroy(); //may have to play with that number

Also, it's weird, but if the above doesn't work on its own, then put the following in the CREATE event:

image_index = 4/4-1; //using fractions allows whole integers for frames
  • 0

#5 RedbacK

RedbacK

    GMC Member

  • New Member
  • 63 posts
  • Version:Unknown

Posted 24 April 2012 - 07:18 AM

i set sprite to 144 frames shrink/720 deg rotate
then set index to 1 but still happens

also wouldnt i need to set > 70 as the image index fins at 71 not 72 (0-71)
  • 0

#6 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 24 April 2012 - 07:27 AM

i set sprite to 144 frames shrink/720 deg rotate
then set index to 1 but still happens

also wouldnt i need to set > 70 as the image index fins at 71 not 72 (0-71)


You can set the image_index to 1, but the image_speed will determine a continuing animation. When you set the image_index to 1, set the image_speed to 0.

Also, your second sentence is correct. If image_index > 70 {image_index = 1; image_speed = 0; blah blah}.
  • 0

#7 RedbacK

RedbacK

    GMC Member

  • New Member
  • 63 posts
  • Version:Unknown

Posted 24 April 2012 - 10:14 AM

i tried having image speed set to 0 and in code did image_index=image_index+.25(or .5 or 1..same result)
  • 0

#8 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 9280 posts
  • Version:GM8

Posted 24 April 2012 - 02:23 PM

Do NOT use decimals. That's what integrate was trying to tell you. Decimals addition does not work properly with floating points. Use 1/4, not .25. Let GM handle the math, don't try to do it yourself, because 4*.25 is not equal to 4*1/4.
  • 0

#9 RedbacK

RedbacK

    GMC Member

  • New Member
  • 63 posts
  • Version:Unknown

Posted 24 April 2012 - 11:21 PM

it still does it if i set speed as 1

Im gunna try just shrinking and rotating the current sprite instead of changing sprite, see if that works.....

Edited by RedbacK, 24 April 2012 - 11:22 PM.

  • 0

#10 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 9280 posts
  • Version:GM8

Posted 25 April 2012 - 01:15 AM

Are you sure you're not telling it to use the old animation somewhere else in the code or in another object?

... Also, quick question: What's the actual code for the effect? It sounds like you have some syntax errors at the root of the problem.
  • 0

#11 ParodyKnaveBob

ParodyKnaveBob

    theUndiscovered

  • GMC Member
  • 1231 posts
  • Version:GM:Studio

Posted 25 April 2012 - 06:35 AM

Howdy,

Just off the top of my head, it sounds to me like you're overcomplicating things.

1. change sprite to shriveling animation
2. in Animation End Event, check if sprite index is shriveling sprite
3. if it is, then destroy

I hope this helps, $:^ J
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users