||Posted - Dec 07 2006 : 4:42:59 PM
I am working on a 2d game using the dxgame engine v. dxg231.
While the dxgame forum is down, can anyone here tell me how to set up a simple sprite animation sequence using dxg? That way I can get the tires on my car to look like they are rolling
here is a pic of the game in progress I am working on...
||Posted - Dec 20 2006 : 11:53:58 AM
I'll second that... Dave, you just worry about family. We'll be here...
ps. I'm very glad to be making contact with SOMEONE from the old forum though! I've missed all the good times!
||Posted - Dec 09 2006 : 10:30:24 AM
Thank you dave. All of us dxg users know you are going through a lot right now, so don't be sorry for any delays. You have a lot of friends out here who just hope you make it through everything ok.
||Posted - Dec 09 2006 : 02:13:34 AM
There are a few ways to init your animations, this one can be done directly in code without using an external file.
DX.SpriteAnimate.Add Index, SrcX, SrcY, FrameWidth, FrameHeight, AnimLength, Frame$, Texture$
Index - Which animation index to setup. Start at 1 and proceed upward.
SrcX,SrcY - This is the topleft pixel where the animation image data starts on the texture. Remember to leave a 1 pixel border to the right and at the bottom in between each frame.
FrameWidth, FrameHeight - How wide/tall each animation frame is. Do NOT include the border pixel.
AnimLength - How many frames of animation.
Frame$ - A string representing each grid location for each frame of the animation. This is not in pixels. This allows you to set up complex animations using a combination of horizontal or vertical strips. Each pair of numbers represents where the frame is, horzontal/vertical.
For example, if you had 2 frames of animation next to each other on a horizontal plane the string would simply be: "0,0,1,0". If you had 4 frames it would be "0,0,1,0,2,0,3,0". Notice how the horizontal grid is incremented for every frame but the vertical grid does not. Lets say you had 9 frames arranged in a 3x3 grid pattern, the frame data would be defined as this:
Note that the frame numbers stay the same REGARDLESS where on the texture the animation data starts.
Texture$ - This string simply holds the texture index for each frame of the animation. This allows you if desired, to create animations from several loaded textures. But for ease of use, try to keep all of your animations on 1 texture. Each string value represents 1 frame of the animation. So if you had 6 frames of animation, and each frame of the animation was on texture 1 it would look like this:
It all quickly makes sense once you start playing with it. ;)
To start a sprite using a looping animation, use this:
DX.SpriteAnimate.Repeat Sprite, AnimIndexAsLong, AnimSpeedAsSingle
AnimIndex - The previously set up anim index number.
AnimSpeed - The speed of the animation. A floating point number. Play around with values such as, .005, .05, .1, etc. The higher the number, the faster the animation will play.
Sorry for the delays at the DXG site. As unbelievable as it sounds, after experiencing my Mother's death recently, my Wife's Father just passed away yesterday. I'll be glad when 2006 is over to say the least. :(