Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Same dbSprite() using multiple images

Author
Message
Froobzi
13
Years of Service
User Offline
Joined: 16th Jul 2011
Location:
Posted: 16th Jul 2011 19:13
Hello guys and thanks for reading my thread. First of all I would like to say that I am a complete newby to dark GDK though not to programming in general. I am learning C/C++ still but I know the basics so far. Anyway I hope I posted this into the right place, please correct me if not.

I am currently working on a game with my younger brother (hes a good pixel artist, anyways) Here is a snippet of my code, question following:



Ok I experimented with a few things here .. I have defined the variable Facing to help me know which side I am currently facing in order to play other animations correctly sided, CurrentDirection I use for telling me basicaly if I changed the position, because then it has to stop the current animation by setting it to the correct dbSetSpriteFrame() in order to fix those issues I had that played my last animation to end before they started new one (looked laggy).

Here is my question:
As you can see I made two animations one for the Walk and other for the Jump cycle. I would like to know how could I use two different animations on a single sprite? Or could I simply make a new sprite somehow, position it to where the old one was and then delete the old one? The thing is my brother made about 100 different animations x) .. well the sprite sheet is so huge and has things of various sizes, it could be a little problem to resize that all correctly.

I wanted to use small animation packets and call them when I need them on different parts of my code. I tried both animations seperated and they work perfectly. Running/Standing on both left and right works. Now when I try to make the "jump" i come into the problem where I have to load the 2nd animation to the first sprite (OR) as I said already recreate one on same location and delete the old one.. Sadly i don't know how I could do this

First idea does not work. When I load a new image to an old sprite it kinda messes the whole thing up.. The animation does not play correctly even that in a seperated sprite it works. So I moved to my second idea..

The second idea was to use the second sprite which when created gave no issues, position it to the correct X/Y location on the screen where the old one was and then delete old one.. The issues here were that I couldnt find a function to return the current X/Y coordinates to me. Also a big trouble would be that dbMoveSprite() and such functions would require a complete change of their parameters...

I am new to dark GDK so I might over look an easy way around this..

Sorry on the huge post. Hope I explained everything well. I gave as much information as I currently have, but if you didn't understand something just ask it right away. I realy cant move on with my project until I fix this..

Thanks in Regrads ~Froobzi
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 17th Jul 2011 18:13 Edited at: 17th Jul 2011 18:45
Quote: "I couldnt find a function to return the current X/Y coordinates to me"


No problem:


You can find them in the help if you look through the sprite-related functions.

Quote: "dbMoveSprite() and such functions would require a complete change of their parameters"


Not if you use a variable instead of a hardcoded number, which is a good idea anyway.



No change in parameters, since you use a variable name instead of a number. (Of course there will be a change in frame numbers in dbPlaySprite if you play a different animation, but that will change even if the sprite is the same, so you must handle that somehow anyway. But there won't be a change in parameters just because it's a different sprite.)

Also, you can hide a sprite instead of deleting it when it is not in use. (dbHideSprite, dbShowSprite.) This way it should be easy to switch between different sprites, and the system doesn't have to reload the images from disk, which would happen if you delete and recreate them.
Froobzi
13
Years of Service
User Offline
Joined: 16th Jul 2011
Location:
Posted: 17th Jul 2011 21:16
Oh thanks a looooot for your post.. I have been working on this issue whole day already and I went into the lets say right way by taking a closer look at hide function. Thanks for the SpriteX/Y tip it works like a charm!! And yes recreating whole sprite by taking the image from disk is probably the worse situation then just hide and call it when I need it again.

Thanks a ton! For the easy and straight foward idea.

Cheers again ~Froobzi
vitinho444
14
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 17th Jul 2011 22:54
Well, of course it works like a charm.

If you want my advise while you are making the game without release you can make this to help you:



This helps you alot to check for errors and trying to see whats is going on that you dont see =D

Hope it helps

C++ Medium 3.5/5
VB6 Advanced: 4/5
VB.NET Advanced: 4/5

Login to post a reply

Server time is: 2024-11-19 09:27:42
Your offset time is: 2024-11-19 09:27:42