[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Slick Forums • View topic - RFE: SpriteSheet constructor for Animation

Slick Forums

Discuss the Slick 2D Library
It is currently Tue Aug 11, 2020 10:15 pm

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed Dec 06, 2006 3:31 pm 
Offline

Joined: Fri Dec 01, 2006 3:56 pm
Posts: 34
Location: The Netherlands
Often you will want to use a SpiteSheet for an animation, like in the AnimationTest:

SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65);
animation = new Animation();
for (int i=0;i<8;i++) {
animation.addFrame(sheet.getSprite(i,0), 150);
}


Since you already provided the sprite width and height, wouldn't it make more sense to have an extra constructor for the Animation object that takes a SpriteSheet and frame-duration as parameters to take away some boilerplate code?
So the lines above could then be written as:

SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65);
animation = new Animation(sheet, 150);


Also it would be nice if the Animation could support pingpong play as well as normal sequential play.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 06, 2006 7:44 pm 
Offline
Oldbie

Joined: Sat Nov 18, 2006 3:11 pm
Posts: 254
Location: Helsinki
sorry , it's not a answer but what is the interest of spriteSheet ? :o


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 06, 2006 9:23 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 06, 2006 11:23 pm 
Offline

Joined: Fri Dec 01, 2006 3:56 pm
Posts: 34
Location: The Netherlands


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 3:41 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 12:51 pm 
Offline

Joined: Fri Dec 01, 2006 3:56 pm
Posts: 34
Location: The Netherlands
Thanks Kev,

I just tried the new updates and there are some problems with the constructor. It also shows up in the AnimationTest.

You have this code in your constructor:
if (horizontalScan) {
for (int x=x1;x<=x2;x++) {
for (int y=0;y<=y2;y++) {
addFrame(frames.getSprite(x, y), duration);
}
}
} else {
for (int y=0;y<=y2;y++) {
for (int x=x1;x<=x2;x++) {
addFrame(frames.getSprite(x, y), duration);
}
}
}

I think it should be:
if (horizontalScan) {
for (int x = x1 ; x < x2 ; x++) {
for (int y = y1 ; y < y2 ; y++) {
addFrame(frames.getSprite(x, y), duration);
}
}
} else {
for (int y = y1 ; y < y2 ; y++) {
for (int x = x1 ; x < x2 ; x++) {
addFrame(frames.getSprite(x, y), duration);
}
}
}
So y1 should be used as a starting point (instead of 0) and the for-expressions should be < instead of <=. If you have only 1 row in your sheet, the loop should cover only y = 0 and not y = 1.

This also means your AnimationTest should be updated to:
pingPong = new Animation(sheet, 0,0,8,1,true,150,true);

I also noticed that this new constructor doesn't set currentFrame to 0 while the other constructors do, although everything does seem to work fine without it.

Do you accept other committers on this project? If so I can commit these changes myself.... oh and is there any way of properly indenting code in this forum? HTML editing seems to be turned off, so I cannot use <pre></pre>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 4:59 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 5:13 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Oh, I'm not accept other committers as yet. I'll post when that changes. Right now I'm just trying to keep the management of consistent changes simple so thing can progress faster. Once things are slowing down I think I'll open it up a bit more.

You can use [ code ] [ /code ] tags (with the spaces removed) to show code here.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 6:47 pm 
Offline

Joined: Fri Dec 01, 2006 3:56 pm
Posts: 34
Location: The Netherlands


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 6:49 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 7:03 pm 
Offline

Joined: Fri Dec 01, 2006 3:56 pm
Posts: 34
Location: The Netherlands


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group