Having Trouble Switching Out 2d Sprite Body Parts

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 1968 Views - Last Post: 13 September 2011 - 09:32 PM

#1 colonelmustang377  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 12-August 11

Having Trouble Switching Out 2d Sprite Body Parts

Posted 16 August 2011 - 07:02 PM

Hi, I am fairly new at programming and I am having a tough time figuring out how to swap out sprite body parts with the press of a button. I am trying to make a game where customizing your character parts (e.g. head,body,arm,legs) will be a big thing.
I already have many individual body parts drawn, my problem is having them: display correctly (I get a wierd stretch effect near the bottom), display in the correct layers (arms over body, etc.), and in the right place (body correctly linked to legs).

I have already been able to put the arms on but they stretch near the bottom, so there is a little progress.

Here is the Game1.cs the next will be the AnimatedSprite.cs logic.

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Another_Animation_Code
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        AnimatedSprite sprite;
        AnimatedSprite arm;
        

        

        

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            sprite = new AnimatedSprite(Content.Load<Texture2D>("Sprites\\ProjectBCharactersAlphaSmall"), new Point(1,0),25,34);
            arm = new AnimatedSprite(Content.Load<Texture2D>("Sprites\\smallgoldarms"), new Point(1,20), 25, 11);
            sprite.Position = new Vector2(200,300);
            arm.Position = new Vector2(200,297);
            
            // TODO: use this.Content to load your game content here
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)||(Keyboard.GetState().IsKeyDown(Keys.Escape)))
                this.Exit();

            // TODO: Add your update logic here
            sprite.HandleSpriteMovement(gameTime);
            arm.HandleSpriteMovement(gameTime);
            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            spriteBatch.Begin();
            spriteBatch.Draw(sprite.Texture, sprite.Position, sprite.SourceRect, Color.White, 0f, sprite.Origin, 1.0f,sprite.SpriteFlipState , 0);
            
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}





Here is the AnimatedSprite.cs, this is the logic.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;



namespace Another_Animation_Code
{
    class AnimatedSprite
    {
        Texture2D spriteTexture;
        KeyboardState currentKBState;
        KeyboardState previousKBState;

        float timer = 0f;
        float interval;
        float FPS = 22;

        Point currentFrame = new Point(1,1);
        int spriteWidth;
        int spriteHeight;
        int spriteSpeed = 2;

        Rectangle sourceRect;
        Vector2 position;
        Vector2 origin;

        SpriteEffects spriteFlipState = SpriteEffects.None;
        SpriteEffects spriteSwitch = SpriteEffects.None;
        

        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }
        public Vector2 Origin
        {
            get { return origin; }
            set { origin = value; }
        }
        public Texture2D Texture
        {
            get { return spriteTexture; }
            set { spriteTexture = value; }
        }
        public Rectangle SourceRect
        {
            get { return sourceRect; }
            set { sourceRect = value; }
        }
        public SpriteEffects SpriteFlipState
        {
            get { return spriteFlipState; }
            set { spriteFlipState = value; }
        }

        public AnimatedSprite(Texture2D texture, Point currentFrame, int spriteWidth, int spriteHeight)
        {
            this.spriteTexture = texture;
            this.currentFrame = currentFrame;
            this.spriteWidth = spriteWidth;
            this.spriteHeight = spriteHeight;
        }

        public void HandleSpriteMovement(GameTime gameTime)
        {
            previousKBState = currentKBState;
            currentKBState = Keyboard.GetState();
            interval = (float)1 / FPS;
            

            sourceRect = new Rectangle(currentFrame.X * spriteWidth,currentFrame.Y * spriteHeight, spriteWidth, spriteHeight);
            

            if (currentKBState.GetPressedKeys().Length == 0)
            {
                if (currentFrame.X > 0 && currentFrame.X < 23)
                {
                    currentFrame.X= 0;
                }
                if (currentFrame.Y > 20 && currentFrame.Y < 25)
                {
                    currentFrame.Y = 20;
                }
                
            }

            if (currentKBState.IsKeyDown(Keys.Space))
            {
                spriteSpeed = 3;
                FPS = 44;
            }
            else
            {
                spriteSpeed = 2;
                FPS = 22;
            }

            if (currentKBState.IsKeyDown(Keys.Right) == true)
            {
                AnimateRight(gameTime);
                if (position.X < 780)
                {
                    position.X += spriteSpeed;
                }
                spriteFlipState = SpriteEffects.None;
            }
            else if (currentKBState.IsKeyDown(Keys.Left) == true)
            {
                AnimateLeft(gameTime);
                if (position.X > 20)
                {
                    position.X -= spriteSpeed;
                }
                spriteFlipState = SpriteEffects.FlipHorizontally;
            }
            if (currentKBState.IsKeyDown(Keys.Z) == true)
            {
                
            }
           
           
            origin = new Vector2(sourceRect.Width / 2, sourceRect.Height / 2);
        }

        public void AnimateRight(GameTime gametime)
        {
            if (currentKBState != previousKBState)
            {
                currentFrame.X = 0;
            }
            timer += (float)gametime.ElapsedGameTime.TotalMilliseconds;

            if (timer > interval)
            {
                currentFrame.X++;
                if (currentFrame.X > 23)
                {
                    currentFrame.X = 0;
                }
                timer = 0f;
            }
        }
        public void AnimateLeft(GameTime gametime)
        {
            if (currentKBState != previousKBState)
            {
                currentFrame.X = 0;
            }
            timer += (float)gametime.ElapsedGameTime.TotalMilliseconds;

            if (timer > interval)
            {
                currentFrame.X++;
                
                if (currentFrame.X > 23)
                {
                    currentFrame.X = 0;
                }
                timer = 0f;
            }

        }

        
        
        

    }
}





Is This A Good Question/Topic? 0
  • +

Replies To: Having Trouble Switching Out 2d Sprite Body Parts

#2 ShadowsEdge19  Icon User is offline

  • D.I.C Addict

Reputation: 142
  • View blog
  • Posts: 664
  • Joined: 16-January 10

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 17 August 2011 - 05:57 AM

I can't see where you are drawing the "arm" AnimatedSprite object in game1() as I can only see "sprite" being drawn there. Also for the other point it would be useful to draw all the body parts relative to the main sprite object (I'm presuming that is the centre piece, i.e. the torso and head), so something like:

rightArmPos = new Vector2(sprite.X + sprite.Width, sprite.Y - (sprite.Height/2))

So the right arm is attached to the far right side of the sprite and roughly half way down.
Was This Post Helpful? 0
  • +
  • -

#3 colonelmustang377  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 12-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 17 August 2011 - 04:49 PM

View PostShadowsEdge19, on 17 August 2011 - 05:57 AM, said:

I can't see where you are drawing the "arm" AnimatedSprite object in game1() as I can only see "sprite" being drawn there. Also for the other point it would be useful to draw all the body parts relative to the main sprite object (I'm presuming that is the centre piece, i.e. the torso and head), so something like:

rightArmPos = new Vector2(sprite.X + sprite.Width, sprite.Y - (sprite.Height/2))

So the right arm is attached to the far right side of the sprite and roughly half way down.


Actually, I got the arms to fit (since I drew them together). But the legs (which I also drew as one sprite) are glitching, they stretch out downwards and I cannot figure out why.

Here is some new Game1.cs code
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Another_Animation_Code
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        AnimatedSprite sprite;
        AnimatedSprite arms;
        AnimatedSprite legs;
        AnimatedSprite head;
        AnimatedSprite body;
        

        

        

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            sprite = new AnimatedSprite(Content.Load<Texture2D>("Sprites\\ProjectBCharactersAlphaSmall"), new Point(1,0),25,34);
            arms = new AnimatedSprite(Content.Load<Texture2D>("Sprites\\smallgoldarms"), new Point(1,20), 25, 11);
            legs = new AnimatedSprite(Content.Load<Texture2D>("Sprites\\smalllegs"), new Point(1, 2), 25, 16);
            head = new AnimatedSprite(Content.Load<Texture2D>("Sprites\\smallhead"), new Point(1, 4), 25, 11);
            body = new AnimatedSprite(Content.Load<Texture2D>("Sprites\\small body"), new Point(1,12), 24, 13);
            sprite.Position = new Vector2(200, 300);
            arms.Position = new Vector2(200, 297);
            legs.Position = new Vector2(200, 310);
            head.Position = new Vector2(200, 285);
            body.Position = new Vector2(200, 300);
            
            // TODO: use this.Content to load your game content here
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)||(Keyboard.GetState().IsKeyDown(Keys.Escape)))
                this.Exit();

            // TODO: Add your update logic here
            sprite.HandleSpriteMovement(gameTime);
            arms.HandleSpriteMovement(gameTime);
            legs.HandleSpriteMovement(gameTime);
            head.HandleSpriteMovement(gameTime);
            body.HandleSpriteMovement(gameTime);
            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            spriteBatch.Begin();
            spriteBatch.Draw(sprite.Texture, sprite.Position, sprite.SourceRect, Color.White, 0f, sprite.Origin, 1.0f,sprite.SpriteFlipState , 0);
            spriteBatch.Draw(arms.Texture, arms.Position, sprite.SourceRect, Color.White, 0f, arms.Origin, 1.0f, arms.SpriteFlipState, 0);
            spriteBatch.Draw(legs.Texture, legs.Position, legs.SourceRect, Color.White, 0f, legs.Origin, 1.0f, legs.SpriteFlipState, 0);
            spriteBatch.Draw(head.Texture, head.Position, head.SourceRect, Color.White, 0f, head.Origin, 1.0f, head.SpriteFlipState, 0);
            spriteBatch.Draw(body.Texture, body.Position, body.SourceRect, Color.White, 0f, body.Origin, 1.0f, body.SpriteFlipState, 0);
            
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}




I also attached a picture of the build. I edit the size of the guy on paint.net for the sake of being able to see it clearly.

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#4 goat  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 13
  • Joined: 19-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 23 August 2011 - 07:18 PM

Hi,

I don't have VS installed on this machine so I can't check your argument line - however, it looks like checking the source rectangle assigned to the legs might be an idea. Try explicitly setting the source and seeing if that changes any behaviour.

To my memory if you pass a Rectangle rather than a Vector2 as the second argument in spriteBatch.Draw, it will explicitly scale the sprite to fit that size. While fixing the actual problem is probably a better idea, this would allow you to lock the size of the legs.
Was This Post Helpful? 0
  • +
  • -

#5 goat  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 13
  • Joined: 19-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 23 August 2011 - 09:17 PM

Actually, as an additional consideration - while I can probably reassemble the code you've pasted here and identify what might be going wrong, would you be able to supply the original project?
Was This Post Helpful? 0
  • +
  • -

#6 colonelmustang377  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 12-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 26 August 2011 - 06:44 PM

View Postgoat, on 23 August 2011 - 09:17 PM, said:

Actually, as an additional consideration - while I can probably reassemble the code you've pasted here and identify what might be going wrong, would you be able to supply the original project?


Thanks for all of the help. I am not able to upload the file for some reason, do you want me to email it to you?
Was This Post Helpful? 0
  • +
  • -

#7 colonelmustang377  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 12-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 26 August 2011 - 07:07 PM

View Postcolonelmustang377, on 26 August 2011 - 06:44 PM, said:

View Postgoat, on 23 August 2011 - 09:17 PM, said:

Actually, as an additional consideration - while I can probably reassemble the code you've pasted here and identify what might be going wrong, would you be able to supply the original project?


Thanks for all of the help. I am not able to upload the file for some reason, do you want me to email it to you?


Actually, I am having trouble puting each sprite on an individual layers. Right now I think they are all blending and causing this graphical hiccup.
Here is my situation, I have multiple sprites diplaying right now (template(whole guy), arms, body, legs, head) the template (entire person) by itself works fine, the arms you can see but are glitches, as soon as anything else is added the arms go away and the sprites are streched.

I hope this help.
Was This Post Helpful? 0
  • +
  • -

#8 goat  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 13
  • Joined: 19-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 26 August 2011 - 08:25 PM

If you could upload it to mediafire it might be better.

It will be relatively easy, I think, to determine what's going on once I can poke through it a bit.
Was This Post Helpful? 0
  • +
  • -

#9 colonelmustang377  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 12-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 28 August 2011 - 01:36 PM

View Postgoat, on 23 August 2011 - 09:17 PM, said:

Actually, as an additional consideration - while I can probably reassemble the code you've pasted here and identify what might be going wrong, would you be able to supply the original project?


Do you just need the source code?
Was This Post Helpful? 0
  • +
  • -

#10 ShadowsEdge19  Icon User is offline

  • D.I.C Addict

Reputation: 142
  • View blog
  • Posts: 664
  • Joined: 16-January 10

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 28 August 2011 - 02:35 PM

I think it would be easier if he had both the source code and your original sprite content as it would be difficult to work out what content he would need in order to replicate your current problems.
Was This Post Helpful? 0
  • +
  • -

#11 colonelmustang377  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 12-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 28 August 2011 - 11:42 PM

View PostShadowsEdge19, on 28 August 2011 - 02:35 PM, said:

I think it would be easier if he had both the source code and your original sprite content as it would be difficult to work out what content he would need in order to replicate your current problems.

I appreciate the explanation. I managed to upload, hopefully, all of what you need.
Here;'s the link http://www.mediafire...y6hfgbmbmoesfob
Was This Post Helpful? 0
  • +
  • -

#12 goat  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 13
  • Joined: 19-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 29 August 2011 - 02:21 PM

Hi,

Thank you - I will try to build the project when I get home and see if I can figure out what the issue is.
Was This Post Helpful? 1
  • +
  • -

#13 goat  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 13
  • Joined: 19-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 01 September 2011 - 04:33 AM

Hi,

Sorry for the delay in my response but work, as usual, started creeping into life.

Anyway, the issue seems to be when you're defining your sourceRect.

By using this code

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            arms.SourceRect = new Rectangle(0, 0, 23, 11);

            // TODO: Add your drawing code here
            spriteBatch.Begin();
            //spriteBatch.Draw(sprite.Texture, sprite.Position, sprite.SourceRect, Color.White, 0f, sprite.Origin, 1.0f,sprite.SpriteFlipState , 0);
            spriteBatch.Draw(arms.Texture, arms.Position, arms.SourceRect, Color.White, 0f, arms.Origin, 1.0f, arms.SpriteFlipState, 0);
            //spriteBatch.Draw(legs.Texture, legs.Position, legs.SourceRect, Color.White, 0f, legs.Origin, 1.0f, legs.SpriteFlipState, 0);
            //spriteBatch.Draw(head.Texture, head.Position, head.SourceRect, Color.White, 0f, head.Origin, 1.0f, head.SpriteFlipState, 0);
            //spriteBatch.Draw(body.Texture, body.Position, body.SourceRect, Color.White, 0f, body.Origin, 1.0f, body.SpriteFlipState, 0);
            
            spriteBatch.End();

            base.Draw(gameTime);
        }



The arms display correctly (Of course you should not assign a value to an object during Draw when it's meant to be done during Update, but this is just proving the issue) - so I would surmise that the issue is how your rectangle is being returned or set in the first place.
Was This Post Helpful? 1
  • +
  • -

#14 colonelmustang377  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 12-August 11

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 03 September 2011 - 04:30 PM

View Postgoat, on 01 September 2011 - 04:33 AM, said:

Hi,

Sorry for the delay in my response but work, as usual, started creeping into life.

Anyway, the issue seems to be when you're defining your sourceRect.

By using this code

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            arms.SourceRect = new Rectangle(0, 0, 23, 11);

            // TODO: Add your drawing code here
            spriteBatch.Begin();
            //spriteBatch.Draw(sprite.Texture, sprite.Position, sprite.SourceRect, Color.White, 0f, sprite.Origin, 1.0f,sprite.SpriteFlipState , 0);
            spriteBatch.Draw(arms.Texture, arms.Position, arms.SourceRect, Color.White, 0f, arms.Origin, 1.0f, arms.SpriteFlipState, 0);
            //spriteBatch.Draw(legs.Texture, legs.Position, legs.SourceRect, Color.White, 0f, legs.Origin, 1.0f, legs.SpriteFlipState, 0);
            //spriteBatch.Draw(head.Texture, head.Position, head.SourceRect, Color.White, 0f, head.Origin, 1.0f, head.SpriteFlipState, 0);
            //spriteBatch.Draw(body.Texture, body.Position, body.SourceRect, Color.White, 0f, body.Origin, 1.0f, body.SpriteFlipState, 0);
            
            spriteBatch.End();

            base.Draw(gameTime);
        }



The arms display correctly (Of course you should not assign a value to an object during Draw when it's meant to be done during Update, but this is just proving the issue) - so I would surmise that the issue is how your rectangle is being returned or set in the first place.


Thanks for your time! The arms do display correctly. However,the aniamtion now does not run, it follows the body but never actually starts. What I did was add the " = new Rectangle(0,0,25,11)" line after the "arms.SourceRect" line. Please tell me if i did somthing wrong because I think I did.

spriteBatch.Draw(arms.Texture, arms.Position, arms.SourceRect = new Rectangle(0,0,25,11), Color.White, 0f, arms.Origin, 1.0f, arms.SpriteFlipState, 0);


Was This Post Helpful? 0
  • +
  • -

#15 ShadowsEdge19  Icon User is offline

  • D.I.C Addict

Reputation: 142
  • View blog
  • Posts: 664
  • Joined: 16-January 10

Re: Having Trouble Switching Out 2d Sprite Body Parts

Posted 03 September 2011 - 05:07 PM

Something is really wrong with your source rectangle as I just ran a debug at the first time it draws.

Sprite = x0, y0, w25, h34
Arms = x0, y0, w23, h11
Legs = x0, y32, w25, h16
Head = x0, y34, w25, h11
Body = x0, y156(!?), w24, h13

Why is the default position of the body y156 when the others are around y32-34?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2