Sign in to follow this  
Noods

Finding the appropriate data type...

Recommended Posts

I am working with sprite coordinate information stored in XML. I have just worked through ingesting my data and I am now trying to figure out what data type I should use to store it. I can't figure out a way to implment this. Here is the data I need to store: Animations - I need one object for each animation that I will store. I need to be able to create and call this object dynamically. This object will contain the following objects: an integer that holds the index number of the animation an integer that holds the number of frames in the animation several frame objects Frames - I need one frame object for each frame in every animation. I need to be able to create and call this object dynamically and every animation may have a different number of frames. This object will contain the following data types: an integer that holds the index number of the frame an integer that holds the width of the frame an integer that holds the height of the frame an integer that holds the top left x coordinate an integer that holds the top left y coordinate I am having a hard time wrapping my head around this. Does anyone have any suggestions? Thanks!

Share this post


Link to post
Share on other sites
I don't get it...what's your problem? What data type? Unsigned int/short?

You are probably programming in an object-oriented language, so perhaps you could create some objects to encapsulate the necessary data.

Create an Animation class that contains some basic variable fields as well as some Frame objects.
Create a Frame class that contains basic variable fields for the necessary information.

Share this post


Link to post
Share on other sites
My problem is that I am not really sure how to implement it or what data types will suffice for this. I'm not sure how to create the main animation object dynamically and I am not sure what data type will hold a dynamically selected number of frame objects.

Share this post


Link to post
Share on other sites
class Animations
{
private int animation_index;
private int number_of_frames;
private List<Frames> frames;
}

class Frame
{
private int frame_index;
private int width;
private int height;
private top_left_x;
private top_left_y;
}

That should take care of the basics.

theTroll

Share this post


Link to post
Share on other sites
I'm not sure what this declaration is.

Quote:
Original post by TheTroll

private List<Frames> frames;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this