Game Development Community

Pick Animation Maps

by Harrison Brock · in Torque X 2D · 02/18/2007 (3:20 pm) · 31 replies

I have 10 Animation map with about 30 frames each. I need a way to pick two animation at a time. These will be falling block. I know how to set the animation in the TorqueX editor because its the same as TBG. But how would I Random pick two of the animation maps here is what I need.

A = a animation map. B = a animation map.

When the game starts the images should be like this.

A
B
The player should be able to rotate a around B Like this.

BA B AB
A

I know I can mount the two together and dismount they when I need two. I just need help on get start with this.
Page«First 1 2 Next»
#21
02/21/2007 (3:56 pm)
@Harrison - There are a lot of ways you could do this. One way would be to put each of your 10 Animations into the scene in TGBX, give them names and mark them as Templates in the Scripting rollout. Then you could put the names in an array or list in C# code, and do something like this:
string[] AnimationNames = { "anim1", "anim2", "blockA", "blockB" };

int RandomChoice1 = GarageGames.Torque.Util.TorqueUtil.GetRandomInt(0, AnimationNames.GetLength(0));
string NameOfMyBlock1 = AnimationNames[RandomChoice1];
int RandomChoice2 = GarageGames.Torque.Util.TorqueUtil.GetRandomInt(0, AnimationNames.GetLength(0));
string NameOfMyBlock2 = AnimationNames[RandomChoice2];

T2DAnimatedSprite Block1 = TorqueObjectDatabase.Instance.CloneObject<T2DAnimatedSprite>(NameOfMyBlock1);
// set Block1.Position
if (Block1 != null)
{
    TorqueObjectDatabase.Instance.Register(Block1);
}

T2DAnimatedSprite Block2 = TorqueObjectDatabase.Instance.CloneObject<T2DAnimatedSprite>(NameOfMyBlock2);
// set Block2.Position
if (Block2 != null)
{
    TorqueObjectDatabase.Instance.Register(Block2);
}
I'm still not 100% sure I understand your question, so let me know if I don't seem to be answering the question you're asking.
#22
02/21/2007 (4:36 pm)
Thanks that help a little. I have this working in TGB with one game that I worked on a few months ago. I most have it work with XNA. I am just start to use torqueX it will take some time to learn how things are done here.
#23
02/22/2007 (8:57 am)
If you still don't get it working Harrison, I would suggest posting the code here that you did in TGB and we can help you port it to TX.

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#24
02/24/2007 (7:32 pm)
This link http://www.garagegames.com/mg/forums/result.thread.php?qt=58370

Is kind of what I have in TGB for my code. Just need for porting to C#
#25
02/24/2007 (8:33 pm)
Which part of that code can't you port? It looks like it should go almost exactly over to C#. You would need to change variable names from the %whatever to actual C# variables you've created, but that's extremely basic stuff.

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#26
02/24/2007 (8:50 pm)
Where do I put the call function calls at and stuff like that.
#27
02/24/2007 (9:44 pm)
Where do I put the call function calls at and stuff like that.
#28
02/24/2007 (10:40 pm)
You would check in gameupdate or in the tick event of whatever component is spawning the pieces. Do whatever tests you need and then call the proper method. Is that what you mean? Maybe you should write some of the code out and then paste in what you have and what it's not doing (or where the error is)?

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#29
02/25/2007 (7:06 pm)
Hey TBG is a little easier to work with. Here is what I have done.
1. Create all my animaton with the animaton builder in torqueX.
2. Save all the animation with names like this anim1, anim2 and so on.

Here is some code I did to try to make a block.

T2DAnimatedSprite block1 = TorqueObjectDatabase.Instance.CloneObject("animAnimation1");
block1.SetPosition(POS, false);
TorqueObjectDatabase.Instance.Register(block1);

So right am trying some easy. I want this animation to be draw at Pos(50,50) when I press a key. I have this set up in TGB and am just learn to use torqueX.

Do I need to create a class to create by blocks? Am use 3 function to do this in TGB. almost like Danny did: http://www.garagegames.com/mg/forums/result.thread.php?qt=58370

So should I put these function into a class to create by block the same way?
#30
02/26/2007 (12:44 pm)
I would make a block component which you can add to those animations. The block component can handle all the movements, speeds, animations, etc. and that's where i'd put those methods that Danny did.

I think your judgement of TGB being easier to use is based on the fact that you had examples of exactly what to do and possibly didn't completely create them yourself. Once you learn the basics of .net, C# and TX, I think you'll find doing stuff in TGBX/TX much easier and quicker than TGB/TS.

Here is a great site for learning .net that I've used many times: www.learnvisualstudio.net

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#31
02/26/2007 (1:12 pm)
I 1 1
Page«First 1 2 Next»