Edited by Silvess, 02 July 2012 - 11:00 PM.
Need an easy method **NOT SOLVED***
#1
Posted 27 June 2012 - 01:14 PM
#2
Posted 27 June 2012 - 01:22 PM
it would be easier to have 4 sprites. 1 for each direction. and then when vspeed is negative then have the sprite change to up. and so on.
this is the easy way to acomplish this but you might not want to take all the time converting it to 4 different sprites.
#3
Posted 27 June 2012 - 01:33 PM
#4
Posted 27 June 2012 - 01:43 PM
if (RunningForward == true) { image_index = (image_index mod 4 )+4 }
This makes it so the minium value of image_index is 4 while the maximum is 7. Mod takes the remainder of the division x/y (x mod y) the number you'd use as y would always be equal to the number of frames that specific animation while the number after (z) would always be equal to the image_index it starts on. You'll need a way to manage all the states though you can either use different variables like the example above or use a state holder and constantsState = RUNNINGFORWARD ; State = RUNNINGLEFT ;
Where you have declared RUNNINGFORWARD and all other constants in the constants tab. You can then use a switch statement to change
switch(State)
{
case RUNNINGFORWARD : { image_index = (image_index mod 4 )+4 } ;break;
case RUNNINGLEFT : { image_index = (image_index mod 4 )+8 } ;break;
}
#5
Posted 27 June 2012 - 01:56 PM
variables
Up = ""
Down = ""
Left = ""
Right = ""
then have code in step
if vspeed < 0
{Up = true}
else Up = false
*do that for all the direction*(you could incoperate it with you movement code all together)
then have it so that it loops the sprite
Sprite
index 1-3 = up 4-6 = down 7-9 = left 10-12 = right
if Up = true {image_index = 1 if image_index > 3 {
image_index = 1
}}
this would be the startings of me completing what your asking but i might be wrong since its not my project :D but i hope this helps accomplish what your going for
#6
Posted 27 June 2012 - 02:01 PM
#7
Posted 27 June 2012 - 02:05 PM
it could get complicate tho if she plans on the player moving diagnoly because the sprite should have around 5 images each direction that adds up to 40 images not to mention if she adds animations to other things like if you attack or if you do other things in the game......i recommend a text file sayingI would do what robinsblade said. Pretty simple to do actually
index
1-10 - does yada yada yada
11-w/e - doess this
and so forth just so it does not get confusing as mutch :D
#8
Posted 27 June 2012 - 02:07 PM
it could get complicate tho if she plans on the player moving diagnoly because the sprite should have around 5 images each direction that adds up to 40 images not to mention if she adds animations to other things like if you attack or if you do other things in the game......i recommend a text file saying
I would do what robinsblade said. Pretty simple to do actually
index
1-10 - does yada yada yada
11-w/e - doess this
and so forth just so it does not get confusing as mutch :D
Hehe propably a good idea, yeah!
#9
Posted 28 June 2012 - 07:36 PM
well if the above poster didnt answer your problem you can....
variables
Up = ""
Down = ""
Left = ""
Right = ""
then have code in step
if vspeed < 0
{Up = true}
else Up = false
*do that for all the direction*(you could incoperate it with you movement code all together)
then have it so that it loops the sprite
Sprite
index 1-3 = up 4-6 = down 7-9 = left 10-12 = right
if Up = true {image_index = 1 if image_index > 3 {
image_index = 1
}}
this would be the startings of me completing what your asking but i might be wrong since its not my project :D but i hope this helps accomplish what your going for
the problem with this method is that the image jumps right back to 1 after hitting 3. This means that 3 is pretty much skipped making for a very jumpy animation. I need a way of the game detecting that JUST before the image jumps to 4, it goes back to 3, keeping the image 3 running long enough to look like a smooth animation cycle. Any ideas?
#10
Posted 28 June 2012 - 08:21 PM
#11
Posted 28 June 2012 - 08:30 PM
Did you read my previous post?
My code is very complicated do to draw function and I've had to work around using the "image_index" function. I'm not sure I know how to make your code work for animating a drawn sprite. See, right now, I have something like--
draw_sprite_ext(spr_head,img_in_speed,x,y,image_xscale,image_yscale,image_angle,color,image_alpha);
in the draw event and img_in_speed animates at 0.3 when the player is moving. In the step event, I have
img_in_speed+=0.3
and I'm trying to make it only animate a certain start to end image which has become very difficult. I've tried using something like this--
END STEP EVENT:
if speed>=1
{
if img_in_speed<anim_start img_in_speed+=anim_start;
if img_in_speed+0.3>anim_end { img_in_speed -= anim_end - anim_start; }
}and I change the anim_start and anim_end variable depending on the key press for movement. Like, down would be 0-3 and up would be 4-7 and left/right (using image_xscale) would be 8-11. It's been very hard and I really need some help figuring out a good system for this game. Any solutions would be great.
#12
Posted 28 June 2012 - 08:35 PM
#13
Posted 28 June 2012 - 08:59 PM
You realise the argument where you have put img_in_speed is the image_index argument (it'll round to an integer). You do what I outlined on this variable instead. I personally don't understand why you are using your own system to control speed rather than setting image_speed since you seem to be only drawing 1 sprite from the object and always at the same speed. Is there any particular reason you can't use image_speed to control the speed?
Here is an example file of what I'm doing. It seems simple but I get a small jitter in between the sprite transitions.
EXAMPLE FILE--
http://www.mediafire.com/?cvhogvfp8bccvu3
If you can help me out, it would be more than appreciated.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











