Wanted to ask what's the best way to play a full-screen animation on android, say a few hundred frames?
I think it too short for putting it into a movie and messing with videoview. So I guess maybe just rendering each frame as a separate PNG file and having an imageView change its picture by a timer, what do you think?
Thanks!
I think you can use 30 frames/second will be efficient and very useful to you
Related
I have a list of photos in my activity.
I should render those concurrently. so I find the best way to have 3 TextureView at first and change the position of them on scrolling the list. If I create EGLThread each time, It runs correctly, but it has a little delay to update the texture. so I need to have EGLThreads permanently, but I don't know to change the bitmap of each EGLThread. I try so many codes but I couldn't find the solution.
I solved.
should run code in postRunnable in EGLThread
I am stuck showing frame animation in android. My problem is that I have to animate 36 images. The smallest image is 69 kb in size and the biggest(last frame) is 526kb. A total of 11mb. I know its insane but I need to do it. See images below. The app is already made for iphone and I have to port it to android.
Requirements:
smooth animation
no frame loss
consistent with iphone
The solutions I tried are:
AnimationDrawable by providing in xml files. Problems: the start time is almost 6 -12 seconds. Images lose frames so jaggy experience.
Change imageview bitmap inside a handler. Problems: Frame loss and Out of memory
Create a custom imageview class. Define a method showAnimation() and inside it update bitmap and invalidate() the view unitl the last frame. Problems: Not fitting my requirement. This by far gave the best result but not half as required.
I am a noob in opengl and gamedevelopment. I am unable to find any alternative to my problem. Please help.
Smallest image:
Last image:
I can visualize the effect you are aiming at.I guess doing this will require pushing in different images onto the same imageView, with incremental frame rate.|
The accuracy will depend on the number of images you have. Greater the number of images finer will be the precision.
Also you need to implement incremental frame rate. So that it gives a smoother feel.
Doing this should be possible using a simple loop to change the image resource of the imageView Controller. There must be lag between two iterations, this lag will actually be the frame rate.
I think this can give satisfactory results.
Going for openGL, however, you will not need all these images. It will just require one image of the card that will be animated and duplicated to create the final image. This however is a complex piece of task(I think) so if you are catching some dead lines, you must go for a non-openGL solution like the 1st one, I have suggested.
so im trying to make a game with just a simple static background at the moment, but when i draw it to the screen (no scaling being done as the resolution of the image is the same as the screen) it draws the bottom portion of the image incorrectly where the bottom few hundred pixels of the image are exactly the same going down the image. Sorry it's so difficult to explain but being new here i cant actually post an image of what is going wrong.
Now im just using a simple sprite to render this background image. Here is the code being used:
// background layer: another image
background = CCSprite.sprite("WaterBackground.png");
// change the transform anchor point (optional)
background.setPosition(CGPoint.make(GAME_WIDTH/2, GAME_HEIGHT/2));
addChild(background);
am i doing something wrong here? Does Cocos2D not support such large images for sprites? (resolution of 800*1280)
Any help would be greatly appreciated!
Since i am now able to upload images, here are visuals of what is going wrong:
And the problem in my game:
As you can see, the problem is hard to describe. The problem only exists with this larger image; i scaled it down manually in GIMP and then scaled it up for the game and it looked fine (except for being a lower resolution). I also tried scaling down this larger image which still resulted in the same problem. Hopefully you guys can help me as I have no clue what could possibly cause this error. Especially since i read that Cocos2D's max supported image size is 2048*2048 and my image is well within that.
Thanks for any help you guys can provide!
This is due to limitations on the size of textures. Coсos2d-android supports images with a maximum size of 1024 x 1024 pixels.
I faced the same problem and looking for a way to solve it.
EDIT
I found the solution
In cocos2d project open file CCTexture2d.java in org.cocos2d.opengl package and change kMaxTextureSize from 1024 to 2048
I'm not certain, as from your code and looking at the cocos2d code I can't see a definite reason why this would be happening, but given the number of sprites you've got on the screen, i'd definitely take a look at my answer to this question as you may well be hitting one of cocos2d's quirky little rendering faults around multiple sprites. can't hurt to try spritesheets, and it's certainly the correct way to actually do sprites in cocos.
also, definitely create yourself a helper utility to determine the scaling ratio of a device compared to your original image sizes, as unlike on iphone, android does have a pretty much unlimited variation of screen resolutions, and a simple bit of "scale as you load" utility code now will save you lots of time in the future if you want to use this on any other device.
you should try to make one method for adding background,i am doing this this like this way try this hope it will help full for you...here addBackGroundScene is my method and i am adding my background with this method,scrXScaleFactor is maintaining scaling part of my screen try this...
private void addBackGroundScene() {
CCSprite bgForLevel1 = addBackgroundAtOrigin("prelevel1/bgMenu.jpg");
bgForLevel1 .setScaleX(scrXScaleFactor);
bgForLevel1 .setAnchorPoint(0, 0);
addChild(bgForLevel1 );
}
I need to take the bitmap of a web page presented in a WebView, and
draw it somewhere else. I need to do it in high performance - several
times in a second. Anyone has an idea what's the best way of achieving
that? I know how to get the bitmap using webview.buildDrawingCache
and canvas.drawBitmap, but that seem to be a good solution for a
single snapshot only. Also tried overriding onNewPicture, was not enough either.
Getting the bitmap is a must for me, I cannot simply re-scale the
webview.
Thanks,
yakobom
I want to have a cartoonish stork fly across my screen (slowly flapping his wings) and land on a post. I have an artist that can draw it for me and said it could be a gif file. I'm guessing that means it would be like a cartoon movie. Is this easy to put in my app or do I need to do something entirely different? My only experience with any graphics in android is displaying a picture using ImageView.
Thanks for any help.
Android does not deal with animated GIFs well. You apparently can play one back using VideoView, but I have not tried that. You can also set up an AnimationDrawable resource (an XML container for the frames of your animation).
This seems to do what you want:
http://www.androlib.com/android.application.com-ideal-imageviewer-EzCz.aspx