glegris / pulpcore

Automatically exported from code.google.com/p/pulpcore
0 stars 1 forks source link

copy constructor "new AnimatedImage(AnimatedImage image)" doesn't keep the same state of animation. #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1/ when using the 'copy' constructor of AnimatedImage, I expect the current
state of the copy will be exactly the same as the one of the original
animated image, including:

- the copy 'isPlaying' state is equal
- the current frame is the same

This is not the case.

2/ 

CoreImage imgs[] = new CoreImage[3];
imgs[0] = CoreImage.load("image1.png");
imgs[1] = CoreImage.load("image2.png");
imgs[3] = CoreImage.load("image3.png");

AnimatedImage anim = new AnimatedImage(imgs);
anim.setFrame(1);

AnimatedImage anim-copy = new AnimatedImage(anim1);

System.out.println("anim frame = "+anim.getFrame());
// displays '1' ==> OK

System.out.println("anim-copy frame = "+anim-copy.getFrame());
// displays '0' ==> PROBLEM.

Original issue reported on code.google.com by alexandr...@gmail.com on 29 Jul 2009 at 7:06

GoogleCodeExporter commented 9 years ago
That's fine. Care to submit a patch?
CoreImage.load() would also have to change to reset the state of a newly 
created AnimatedImage

Original comment by brack...@gmail.com on 29 Jul 2009 at 9:34

GoogleCodeExporter commented 9 years ago
Actually it would probably be better to have a second constructor, 
AnimatedImage(AnimatedImage src, boolean 
copyState) which optionally copies the state.

Original comment by brack...@gmail.com on 29 Jul 2009 at 11:04

GoogleCodeExporter commented 9 years ago
Added AnimatedImage(AnimatedImage image, boolean copyState) constructor

Original comment by brack...@gmail.com on 2 Aug 2009 at 8:11