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 / Sprite Sheet Problems

Author
Message
ManOfActionTM
13
Years of Service
User Offline
Joined: 16th May 2011
Location: Sahuarita, Arizona
Posted: 31st Jul 2011 03:23
Okay, I'm having a bit of a problem with the sprite sheets.



The sprite shows up, but it's the entire sprite sheet, not the individual sections.
ManOfActionTM
13
Years of Service
User Offline
Joined: 16th May 2011
Location: Sahuarita, Arizona
Posted: 31st Jul 2011 03:25
Okay, I\'m having a bit of a problem with the sprite sheets.



The sprite shows up, but it\'s the entire sprite sheet, not the individual sections.

Edit: fixed part of the code, but still not working correctly.
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 31st Jul 2011 07:39
Personally, I prefer to use the forward-slash "/" instead of the double-back-slash "\\" of windows. With this aside, I have no idea what your sprite-sheet shows but from what you are showing is that it is 9-images tall with a single-column of images (and not as I suspect yours is: 9-images wide with a single-row).

In which case, your:



Is telling it to play Image 9 to Image 1 with a timeframe of 10; which is really only showing three-frames of animation: 9 followed by 0 and 1...

I'm not sure what the *timeframe* really represents within GDK, so I prefer to use the dbSetSpriteFrame() function instead; passing the parameter of the desired frame to set to as I need it set. And follow that with a call to dbPasteSprite(). Don't forget the dbHideSprite() at the top of every frame or else you'll get a *trail* of images...

Even so, I hope this helps you...

JTK
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 31st Jul 2011 18:11 Edited at: 31st Jul 2011 18:11
Make sure that the number of pixels in your sprite sheet is cleanly dividable by the number of images.

Try giving frames 1 to 9 to dbPlaySprite instead of 9 to 1.

If it still doesn't work, post your image, it's hard to tell what the problem can be without seeing the sprite sheet.
ManOfActionTM
13
Years of Service
User Offline
Joined: 16th May 2011
Location: Sahuarita, Arizona
Posted: 31st Jul 2011 22:33
I tried your solutions, and I'm still getting the same problem. The entire spritesheet displays instead of a section of the sheet.

Here is the image:

JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 1st Aug 2011 02:08 Edited at: 4th Aug 2011 00:52
I hope this helps...



As I've said, I don't care to use the dbPlaySprite() because I really don't know what the timer-value represents. Using this method, I can set the animation to any speed I want by changing the TICK_TIME value at the top. The way it is, it will do one full animation cycle every 9/10th's of a second.

Additionally, this code illustrates a *way* to toggle between fullscreen / window'd mode - on the fly (I'd like to thank dark coder for this bit as it really is the easiest way).

Furthermore, it shows a loop that will Decouple the Display loop from the Game Loop.

All of which are *proverbial* standard techniques that I've adopted and offer to you for your perusal (and use if you like)...

Regards,

JTK

EDIT: The image used in this example is a saved version of the image provided in the post above.
Tofu
12
Years of Service
User Offline
Joined: 3rd Aug 2011
Location:
Posted: 3rd Aug 2011 19:25
How do you set how big a frame is?
For example, each of my frames are 25x25, but I don't understand where in the GDK you set the width and height of each frame using dbCreateAnimatedSprite() ?
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 4th Aug 2011 00:43
You don't set the width/height in pixels. You instead set the rows / colums of images for the sprite sheet. The width / height in pixels will automatically calculate for you.

JTK
Tofu
12
Years of Service
User Offline
Joined: 3rd Aug 2011
Location:
Posted: 4th Aug 2011 02:25
Wow........how is that even physically possible? Wow.

Uh well I do have one little problem.
I have a 25x25 sprite (which is from the sprite sheet) and when I blit it to the screen, it doesn't look as big as the actual image, it actually looks more squished and smaller. My screen is 480x320. Any idea why his is happening?
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 4th Aug 2011 19:17 Edited at: 4th Aug 2011 19:22
Without actually seeing your code and images, I'd have to guess that you're seeing the difference in aspect-ratios.

To determine the aspect-ratio, divide the width by the height:

ratio=480/320=1.5

Most screen resolutions (640x480, 800x600, 1024x768 etc) are 1.3333 where each pixel of height is equal to 1.33 pixels of width. In your case, each pixel of height is equal to 1.5 pixels of width. So your image will appear to be wider than it is tall (ie: squished).

You can try using dbSizeSprite() to correct this, although it may distort the image some more. I've never done this but it should work for you.




Hope this helps,

JTK

Edit: In retrospect, you may be able to use dbSetCameraAspect(desired_ratio); which I believe may change your camera's field-of-view to make up the differences for you. Again, I'm not sure about this point either but it's worth a shot...
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 5th Aug 2011 21:44 Edited at: 5th Aug 2011 21:45
@ManOfActionTM:

I tested your sprite sheet with dbCreateAnimatedSprite and dbPlaySprite. It works, but only if I include a dbSprite command into the program to give the coordinates where the sprite should appear. Otherwise the screen is empty. Also, keep in mind that to make the sprite animate, the dbPlaySprite command must be executed every loop, not only once. Here is a small test program that works:



I don't know why your program shows the entire sprite sheet, but doesn't it paste image 90 to the screen somewhere by accident?

You can of course use JTK's solution as well, I was just trying to find out what the original problem was.
ManOfActionTM
13
Years of Service
User Offline
Joined: 16th May 2011
Location: Sahuarita, Arizona
Posted: 10th Aug 2011 10:42 Edited at: 10th Aug 2011 10:44
Sorry about the lack of responses. I've been a bit busy with other parts of my card game, and trying each of your suggestions.

I now have SOMETHING animating, however, it seems to animate through the image numbers instead of the supposedly split up spritesheet.

For example, my first 40 imageNumbers are all cards. After seeing the initial full image, the "animated sprite" goes through the first 8 card numbers (imageNumbers 1-8) instead of the frames of imageNumber 47 (what I provided earlier).

I have it set to repeat when it hits the maximum frame number, so it will cycle through those first 8 imageNumbers over and over again. If I increase the maxSpriteFrameNumber to 50, it'll cycle through the first 50 imageNumbers.

I can use either of the two solutions given in this chain, and both do the same thing. Code is below:


where I declare it:


Sprite TrumpSymbol(47, 90, "Assets\\Clubs_Rotation.png");


where I set it:

TrumpSymbol.changeImage(47); TrumpSymbol.makeAnimated(9, 1);
TrumpSymbol.show();

where I call it:

if (NewBidGame.getBidDecided() && (mouseDelay % 5 == 0))
{
//TrumpSymbol.playAnimation(1, 8, 10);
//TrumpSymbol.display(500, 500);
TrumpSymbol.incrementSpriteFrame();
dbSetSpriteFrame(TrumpSymbol.getSpriteNumber(), TrumpSymbol.getSpriteFrame());
}
ManOfActionTM
13
Years of Service
User Offline
Joined: 16th May 2011
Location: Sahuarita, Arizona
Posted: 10th Aug 2011 10:44
sorry, tried to use the code tags, but they weren't working for me for some reason.

Login to post a reply

Server time is: 2024-05-23 20:19:55
Your offset time is: 2024-05-23 20:19:55