Search Results

Search found 2528 results on 102 pages for 'animation'.

Page 8/102 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • How to update entity states and animations in a component-based game

    - by mivic
    I'm trying to design a component-based entity system for learning purposes (and later use on some games) and I'm having some troubles when it comes to updating entity states. I don't want to have an update() method inside the Component to prevent dependencies between Components. What I currently have in mind is that components hold data and systems update components. So, if I have a simple 2D game with some entities (e.g. player, enemy1, enemy 2) that have Transform, Movement, State, Animation and Rendering components I think I should have: A MovementSystem that moves all the Movement components and updates the State components And a RenderSystem that updates the Animation components (the animation component should have one animation (i.e. a set of frames/textures) for each state and updating it means selecting the animation corresponding to the current state (e.g. jumping, moving_left, etc), and updating the frame index). Then, the RenderSystem updates the Render components with the texture corresponding to the current frame of each entity's Animation and renders everything on screen. I've seen some implementations like Artemis framework, but I don't know how to solve this situation: Let's say that my game has the following entities. Each entity have a set of states and one animation for each state: player: "idle", "moving_right", "jumping" enemy1: "moving_up", "moving_down" enemy2: "moving_left", "moving_right" What are the most accepted approaches in order to update the current state of each entity? The only thing that I can think of is having separate systems for each group of entities and separate State and Animation components so I would have PlayerState, PlayerAnimation, Enemy1State, Enemy1Animation... PlayerMovementSystem, PlayerRenderingSystem... but I think this is a bad solution and breaks the purpose of having a component-based system. As you can see, I'm quite lost here, so I'd very much appreciate any help.

    Read the article

  • Possible iphone animation timing/rendering bug?

    - by David
    Hi all, I have been working on an iphone apps for several weeks. Now I encounter an animation problem that I can't figure out how to resolve. Mayhbe you can help. Here is the details (a little long, bear with me): Basically the effect I want to achieve is, when user click a button, a loading view pops up, hiding the whole screen; and then the apps does a lot of heavy computation, which takes a few seconds. Once the computation is done, soem result views (something likes checkers on a checker board) are rendered under the loading view. Once all result views are rendered, I used animation animation to remove the loading view nand show the result views to the user. Here is what I do: when user click a button, run this code: [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(loadingViewInserted:finished:context:)]; // use a really high index number so it will always on top [self.view insertSubview:loadingViewController.view atIndex:1000]; [UIView commitAnimations]; In the "loadingViewInserted" function, it calls another function doing the heavy computation work. Once the computation is done, a lot of result views (like checkers on a checker board) are rendered under the loading view. for(int colIndex = 1; colIndex <= result.columns; colIndex++) { for(int rowIndex = 1; rowIndex <= result.rows; rowIndex++) { ResultView *rv = [ResultView resultViewWithData:results[colIndex][rowIndex]]; [self.view addSubview:rv]; } } Once all result views are added, following animation is invoked to remove the loading view: [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; [loadingViewController.view removeFromSuperview]; [UIView commitAnimations]; By doing this, most of the time (maybe 90%) it does exactly what I want. However, sometime I see some weird result: the loading view shows up first as expected, then before it disappears, some result views, which suppose to be under the loading view, suddenly appears on top of the loading view; and some of them are partial rendered. And then the loading view curled up, and everything looks normal again. The weird situation only lasts for less than a second, but already bad enough to screw up the UI. I have tried all different kinds of thing to fix this (using another thread to remove the loading view, make the loading view non-transparent), but none of them works. The only thing that makes a little better is, I hide all the result views first; after the last animation finished, in its call back, unhide all result views. But this loses the nice effect that when curling up the loading view, the results are already there. At this point, I really think this is a bug in iphone (I compile it with OS 3.0) OS. Or maybe you can point out what I have done wrong (or could do differently). (thanks for finishing this long post, :-) )

    Read the article

  • Pausing a .gif animation in Google Chrome

    - by Ciaran
    Is it possible to "pause" an animated gif file in Google Chrome? If so, how do I do it? I've tried Esc without luck. I'm aware that other browsers can do this using the Esc key I thought I saw a similar question on here before but couldn't find it - close as dupe if you can find it

    Read the article

  • dz's Open Flash Chart 2 disabling animation problem (Rails)

    - by greg
    How to disable the startup animation in OFC2? Since I started using the dz build, the on-show animation is on by default, which sucks quite a lot. Neither of these work: graph.animate=false graph.on_show=false Also, dz's build implements the tooltip hover support poorly - the tooltip continues to hover even when the cursor is on another flash object. Has anyone overcome these problems?

    Read the article

  • ListView Long Click Animation

    - by spaceboy2000
    I would like to capture long click events in a ListView, which was easily done using a OnItemLongClickListener. However, that lacks the fading animation of the selector transitioning to a long press that is seen when the long click is handled by onCreateContextMenu. How can I get that animation using OnItemLongClickListener?

    Read the article

  • iPhone: Execute code after animation of UIDeviceOrientation change finishes

    - by carloe
    Not sure if I can explain this correctly, but I am trying to execute a method device orientation animation finishes. Right now I have [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];, but that triggers instantly. Is there a way to have it call didRotate after the view rotation animation is completed? Thanks!

    Read the article

  • WPF Animation / Processing priority

    - by Matt B
    Hi all, I have a button which has an animation (in xaml) on it's click event. Cool so far. Problem is that I also have processing occurring on the click event (so I can do stuff) - and this occurs first. How do I prioritise or re-order so that the animation takes place before any custom processing... Thanks.

    Read the article

  • Can you preload images in a dojo animation.

    - by asynchronous-challenged
    I have a dojo animation object of about 15 images. I'm also using dojo.fx.chain to link them all together. Right before I create all my dojo.fadeIn's and dojo.fadeOut's I added in some basic javascript to preload each image. My question is: Am I doing this the hard way or is there some function/attr I can set in the animation object to do this?

    Read the article

  • Libraries for text animation in Flex / Actionscript ?

    - by Simon
    Are there any good libraries for cool text animation effects for use in Actionscript (for use in an intro screen or banner). I've given up tryin to use Flash itself because that takes forever, and I dont know which of the many flash text animation tools to choose from. I'd like to be able to dynamically product cool text effects with different messages.

    Read the article

  • Animation effect on C#

    - by Optimizer
    Can someone point me to a C# open source implementaion with a simple image animations. e.g. I feed the input image to animator, and the animation code produces a few dozen of images which if displayed sequentially looks like animation. I am not something extremely fancy - a simple DirectX filter like animations would do. Thank you.

    Read the article

  • How do I cleanly design a central render/animation loop?

    - by mtoast
    I'm learning some graphics programming, and am in the midst of my first such project of any substance. But, I am really struggling at the moment with how to architect it cleanly. Let me explain. To display complicated graphics in my current language of choice (JavaScript -- have you heard of it?), you have to draw graphical content onto a <canvas> element. And to do animation, you must clear the <canvas> after every frame (unless you want previous graphics to remain). Thus, most canvas-related JavaScript demos I've seen have a function like this: function render() { clearCanvas(); // draw stuff here requestAnimationFrame(render); } render, as you may surmise, encapsulates the drawing of a single frame. What a single frame contains at a specific point in time, well... that is determined by the program state. So, in order for my program to do its thing, I just need to look at the state, and decide what to render. Right? Right. But that is more complicated than it seems. My program is called "Critter Clicker". In my program, you see several cute critters bouncing around the screen. Clicking on one of them agitates it, making it bounce around even more. There is also a start screen, which says "Click to start!" prior to the critters being displayed. Here are a few of the objects I'm working with in my program: StartScreenView // represents the start screen CritterTubView // represents the area in which the critters live CritterList // a collection of all the critters Critter // a single critter model CritterView // view of a single critter Nothing too egregious with this, I think. Yet, when I set out to flesh out my render function, I get stuck, because everything I write seems utterly ugly and reminiscent of a certain popular Italian dish. Here are a couple of approaches I've attempted, with my internal thought process included, and unrelated bits excluded for clarity. Approach 1: "It's conditions all the way down" // "I'll just write the program as I think it, one frame at a time." if (assetsLoaded) { if (userClickedToStart) { if (critterTubDisplayed) { if (crittersDisplayed) { forEach(crittersList, function(c) { if (c.wasClickedRecently) { c.getAgitated(); } }); } else { displayCritters(); } } else { displayCritterTub(); } } else { displayStartScreen(); } } That's a very much simplified example. Yet even with only a fraction of all the rendering conditions visible, render is already starting to get out of hand. So, I dispense with that and try another idea: Approach 2: Under the Rug // "Each view object shall be responsible for its own rendering. // "I'll pass each object the program state, and each can render itself." startScreen.render(state); critterTub.render(state); critterList.render(state); In this setup, I've essentially just pushed those crazy nested conditions to a deeper level in the code, hiding them from view. In other words, startScreen.render would check state to see if it needed actually to be drawn or not, and take the correct action. But this seems more like it only solves a code-aesthetic problem. The third and final approach I'm considering that I'll share is the idea that I could invent my own "wheel" to take care of this. I'm envisioning a function that takes a data structure that defines what should happen at any given point in the render call -- revealing the conditions and dependencies as a kind of tree. Approach 3: Mad Scientist renderTree({ phases: ['startScreen', 'critterTub', 'endCredits'], dependencies: { startScreen: ['assetsLoaded'], critterTub: ['startScreenClicked'], critterList ['critterTubDisplayed'] // etc. }, exclusions: { startScreen: ['startScreenClicked'], // etc. } }); That seems kind of cool. I'm not exactly sure how it would actually work, but I can see it being a rather nifty way to express things, especially if I flex some of JavaScript's events. In any case, I'm a little bit stumped because I don't see an obvious way to do this. If you couldn't tell, I'm coming to this from the web development world, and finding that doing animation is a bit more exotic than arranging an MVC application for handling simple requests - responses. What is the clean, established solution to this common-I-would-think problem?

    Read the article

  • HTML5 Canvas Tileset Animation

    - by Veyha
    How to do in HTML5 canvas Image animating? I am have this code now: http://jsfiddle.net/WnjB6/1/ In here I am can add animations something like - Animation.add('stand', [0, 1, 2, 3, 4, 5]); But how to play this animation? My image drawing function is - drawTile(canvasX, canvasY, tile, tileWidth, tileHeight); Animation['stand']; return 0, 1, 2, 3, 4, 5 I am need something like when I am run Animation.play('stand') run animation from 'stand' array. I am try to do this something like one day, but no have more idea how. :( Thanks and sorry for my bad English language.

    Read the article

  • Core Animation problem on iPhone

    - by Mac
    I'm new to iPhone development, and doing some experimentation with Core Animation. I've run into a small problem regarding the duration of the animation I'm attempting. Basically, Ive got a view with two subviews, and I'm trying to animate their opacity so that one fades in while the other fades out. Problem is, instead of a gradual fade in/out, the subviews simply switch instantly to/from full/zero opacity. I've tried to adjust the animation duration with CATransaction with no noticable effect. It's also not specific to animating opacity - animating position shows the same problem. The code I'm using (inside a method of the superview) follows: CALayer* oldLayer = ((UIView*) [[self subviews] objectAtIndex:0]).layer; CALayer* newLayer = ((UIView*) [[self subviews] objectAtIndex:1]).layer; [CATransaction begin]; [CATransaction setAnimationDuration:1.0f]; oldLayer.opacity = 0.0; newLayer.opacity = 1.0; [CATransaction commit]; Does anyone have an idea what the problem might be?

    Read the article

  • GWT Animation final value is not respected

    - by brad
    I have a FlowPanel that I'm trying to animate back and forth like an iphone nav. (See this post for my original question on how to do this) So I have it "working" with the code shown below. I say working in quotes because I'm finding that my final position of my scroller is not precise and always changes when scrolling. The GWT.log always says the actual values I'm looking for, so for instance with the call below to scrollTo, my GWT.log says: ScrollStart: 0 scrollStop: -246 But when I actually analyze the element in fireBug, its css, left position is never exactly -246px. Sometimes it's off by as much as 10px so my panel has just stopped scrolling before being finished. The worst part is that this nav animates back and forth, so subsequent clicks can really throw it off, and I need pixel perfect positioning otherwise the whole things looks off. I don't even know where to start with debugging this other than what I've already done. Any tips are appreciated. Code to call animation scroller = new Scroller(); scroller.scrollTo(-246,400); Animation Code public class Scroller extends Animation { private FlowPanel scroller; private final Element e; public Scroller(){ scroller = new FlowPanel(); e = scroller.getElement(); } public void scrollTo(int position, int milliseconds) { scrollStart = e.getOffsetLeft(); scrollStop = position; GWT.log("ScrollStart: " + scrollStart + " scrollStop: " + scrollStop); run(milliseconds); } @Override protected void onUpdate(double progress) { double position = scrollStart + (progress * (scrollStop - scrollStart)); e.getStyle().setLeft(position, Style.Unit.PX); } }

    Read the article

  • animation on image view on grid view

    - by yahska
    i am having a grid view with 2 coloums and each item in grid view having one image and 2 textview below the image. i have added one button over each image and after clicking on button i want that image should scale and move down to bottom tab. like it should appear image drop down from its position in side one button of tabview. i am able to add animation on image using this code AnimationSet set = new AnimationSet(true); Animation trAnimation = new TranslateAnimation(0, 160,0, 100); trAnimation.setDuration(500); set.addAnimation(trAnimation); Animation scaleAnimation = AnimationUtils.loadAnimation(this, R.anim.anim_scale); set.addAnimation(scaleAnimation); set.setFillEnabled(true) ; set.setFillAfter(true); view.setAlpha(100) ; view.startAnimation(set); but problem is that image is not coming to bottom of screen it is going inside of grid item where it is placed . anybody knows how to move this image to bottom.

    Read the article

  • Create swipe controlled simple flipbook style animation in ObjC

    - by eco_bach
    Hi I am a beginner in Obj C development, though quite experienced (over 10 years) with other ECMAscript based languages and OOP development. I want to build a simple flipbook style animation, controlled through swiping motion. I'm sure extremely simple for any advanced ObjC coders. Can anyone with extensive ObjC-CocoaTouch experience give me some higher level recommendations? ie, 1 -general application design, should I start with a simple view based application, or navigation based or? 2 -should I use 3rd party animation frameworks such as Cocos2D, or stick with built in classes and methods? 3 -if using built in methods, classes, what is the recommended way of achieving a animation, that will be controlled via swipe and touch gestures? 4 -I want to eventually have multiple 'flipbooks' that I can 'instantly' swap with one another, ie to give the net effect of an object changing color, etc, but not sure how to approach this from a memory management point of view, related to #1 above Except for point 3 above, I'm not expecting any actual code examples. Just general guidelines to follow and perhaps, what are some next steps I should take in my goal as an ObjC code samurai.

    Read the article

  • simple image animation with the keyboard

    - by conorhiggins
    Hi the app I am currently working on requires a simple animation to be performed, which I am able to do but timing is an issue. The app uses the slightly opaque keyboard and I have set up a black background to make it more visually pleasing . The app is a utility app and as the user clicks on a settings button the app will flip which looks great. However there is a problem at the moment in that while the app is flipping the keyboard also closes which itself looks great also, however the background remains. I was wondering if there was a way of animating the background image to follow the keyboard's animation pattern and speed? If I set up a discrete animation time the chances are there will be some sort of overlap and either the image will show too long or the keyboard will show too long. Any suggestions? Another option is to make the keyboard show constantly if anyone knows how to do that? i would rather animate it though as it is quite a simple app and so I would like to make it as aesthetically pleasing as possible. /Conor

    Read the article

  • TabBar as rootController flip animation.

    - by user558076
    Hi there, I'm using a TabBarController as the root controller for my app. I have all the views I use (5 tabs) all hooked together through it in interface builder. What I'm trying to do is trigger a slide or flip animation when moving between tabs. However, I only want this to occur when I change tabs programmatically (ie the animation is triggered when someone does a swipe gesture in the one of the views, but not when they just select one of the tabs). The way I'm currently handling this is by calling: [appDelegate.myTab setSelectedIndex:0]; when the iphone detects a swipe. I've been searching the internet for 5 straight hours and can't seem to find a way to add an animation here. It'd be really cool if there were something like: [appDelegate.myTab setSelectedIndex:0 animated:(YES)]; However, there isn't... I can't imagine no one's ever tried this before, but for the life of me, I can't find anything online that explains how this can be done. Thank you in advance for your help.

    Read the article

  • Improving the efficiency of multiple concurrent Core Animation animations

    - by Alex
    I have a view in my app that is very similar to the month view in the built-in Calendar app. There's a subview that holds the individual cells (a custom UIView subclass that draws text into its layer), and when the user navigates to the next "month", I create the new cells and slide the view to show them. When the animation stops, I remove the old, hidden cells and set things up so it's ready to go for the next animation. This all works nicely. However, I'd like to animate the cells' text color, as in the Calendar app, so that the outgoing ones transition to a lighter color and the incoming ones transition to a darker color. The problems is that I can have as many as 70 cells, so doing individual animations is very slow -- between 5-10 fps on my iPhone 3GS. I'm trying to find a less computationally intense way of doing this. My reading of the Shark results is that the majority of the time is spent redrawing the text for each frame for each frame. This makes sense, since text rendering is hardly the cheapest operation. I've considered creating a second view -- one holding the "outgoing" state and one holding the "incoming" state and using a single opacity animation to gradually reveal the updated cells while both are sliding. I'm concerned that instead of having 70 cells, I'll have 140, which seems like a lot of views. So, is that too many views or would there be a better way of doing this?

    Read the article

  • How do i rotate a CALayer around a diagonal line?

    - by Mattias Wadman
    Hi. I'm trying to implement a flip animation to be used in board game like iPhone-application. The animation is supposed to look like a game piece that rotates and changes to the color of its back (kind of like an Reversi piece). I've managed to create an animation that flips the piece around its orthogonal axis, but when I try to flip it around a diagonal axis by changing the rotation around the z-axis the actual image also gets rotated (not surprisingly). Instead I would like to rotate the image "as is" around a diagonal axis. I have tried to change layer.sublayerTransform but with no success. Here is my current implementation. It works by doing a trick to resolve the issue of getting a mirrored image at the end of the animation. The solution is to not actually rotate the layer 180 degrees, instead it rotates it 90 degrees, changes image and then rotates it back. + (void)flipLayer:(CALayer *)layer toImage:(CGImageRef)image withAngle:(double)angle { const float duration = 0.5f; CAKeyframeAnimation *diag = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"]; diag.duration = duration; diag.values = [NSArray arrayWithObjects: [NSNumber numberWithDouble:angle], [NSNumber numberWithDouble:0.0f], nil]; diag.keyTimes = [NSArray arrayWithObjects: [NSNumber numberWithDouble:0.0f], [NSNumber numberWithDouble:1.0f], nil]; diag.calculationMode = kCAAnimationDiscrete; CAKeyframeAnimation *flip = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.y"]; flip.duration = duration; flip.values = [NSArray arrayWithObjects: [NSNumber numberWithDouble:0.0f], [NSNumber numberWithDouble:M_PI / 2], [NSNumber numberWithDouble:0.0f], nil]; flip.keyTimes = [NSArray arrayWithObjects: [NSNumber numberWithDouble:0.0f], [NSNumber numberWithDouble:0.5f], [NSNumber numberWithDouble:1.0f], nil]; flip.calculationMode = kCAAnimationLinear; CAKeyframeAnimation *replace = [CAKeyframeAnimation animationWithKeyPath:@"contents"]; replace.duration = duration / 2; replace.beginTime = duration / 2; replace.values = [NSArray arrayWithObjects:(id)image, nil]; replace.keyTimes = [NSArray arrayWithObjects: [NSNumber numberWithDouble:0.0f], nil]; replace.calculationMode = kCAAnimationDiscrete; CAAnimationGroup *group = [CAAnimationGroup animation]; group.removedOnCompletion = NO; group.duration = duration; group.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; group.animations = [NSArray arrayWithObjects:diag, flip, replace, nil]; group.fillMode = kCAFillModeForwards; [layer addAnimation:group forKey:nil]; }

    Read the article

  • How do i rotate a CALayer around a diagonal axis?

    - by Mattias Wadman
    Hi, im trying to implement a flip animation to be used in board game like application. The animation is suppose to look like a game piece that rotate and change to the color of its back. I have managed to get a animation that flips around orthogonal axis, but when i try to flip around a diagonal axis by changing the rotation around the z-axis not surprisingly the actual image also gets rotated. Instead i would like to rotate the image as it is around a diagonal axis. I have tried to change layer.sublayerTransform but with no success. Here is the current implementation. It works by doing a trick to resolve the issue of getting a mirrored image at the end of the animation. The solution is to not actually rotate the layer 180 degrees, instead it rotates it 90 degrees, changes image and then rotates it back. + (void)flipLayer:(CALayer *)layer toImage:(CGImageRef)image withAngle:(double)angle { const float duration = 0.5f; CAKeyframeAnimation *diag = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"]; diag.duration = duration; diag.values = [NSArray arrayWithObjects: [NSNumber numberWithDouble:angle], [NSNumber numberWithDouble:0.0f], nil]; diag.keyTimes = [NSArray arrayWithObjects: [NSNumber numberWithDouble:0.0f], [NSNumber numberWithDouble:1.0f], nil]; diag.calculationMode = kCAAnimationDiscrete; CAKeyframeAnimation *flip = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.y"]; flip.duration = duration; flip.values = [NSArray arrayWithObjects: [NSNumber numberWithDouble:0.0f], [NSNumber numberWithDouble:M_PI / 2], [NSNumber numberWithDouble:0.0f], nil]; flip.keyTimes = [NSArray arrayWithObjects: [NSNumber numberWithDouble:0.0f], [NSNumber numberWithDouble:0.5f], [NSNumber numberWithDouble:1.0f], nil]; flip.calculationMode = kCAAnimationLinear; CAKeyframeAnimation *replace = [CAKeyframeAnimation animationWithKeyPath:@"contents"]; replace.duration = duration / 2; replace.beginTime = duration / 2; replace.values = [NSArray arrayWithObjects:(id)image, nil]; replace.keyTimes = [NSArray arrayWithObjects: [NSNumber numberWithDouble:0.0f], nil]; replace.calculationMode = kCAAnimationDiscrete; CAAnimationGroup *group = [CAAnimationGroup animation]; group.removedOnCompletion = NO; group.duration = duration; group.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; group.animations = [NSArray arrayWithObjects:diag, flip, replace, nil]; group.fillMode = kCAFillModeForwards; [layer addAnimation:group forKey:nil]; }

    Read the article

  • how to do android image animation

    - by user270811
    hi, i am trying to get a simple image animation going. i want to make it looks as if the helicopter's propeller blades are turning. i have 3 images for the helicopter, and i am showing one of these images depending on the animation progress. the problem is that all three images end up overlapping each other as opposed to just one image showing up at one time, thereby creating the animation. this is what i did so far, i even tried to clear canvas by doing this canvas.drawColor(Color.BLACK), but that would clear out the whole canvas, which is not what i want. this is what i have: 1) in the View class: static class Helicopter { private long mLastUpdate; private long mProgress = 0; private final float mX; private final float mY; private final Bitmap mHelicopter1; private final Bitmap mHelicopter2; private final Bitmap mHelicopter3; private final float mRadius; Helicopter(long mLastUpdate, float mX, float mY, Bitmap helicopter1, Bitmap helicopter2, Bitmap helicopter3) { this.mLastUpdate = mLastUpdate; this.mX = mX; this.mY = mY; this.mHelicopter1 = helicopter1; this.mHelicopter2 = helicopter2; this.mHelicopter3 = helicopter3; mRadius = ((float) mHelicopter1.getWidth()) / 2f; } public void update(long now) { mProgress += (now - mLastUpdate); if(mProgress >= 400L) { mProgress = 0; } mLastUpdate = now; } public void setNow(long now) { mLastUpdate = now; } public void draw(Canvas canvas, Paint paint) { if (mProgress < 150L) { canvas.drawBitmap(mHelicopter1, mX - mRadius, mY - mRadius, paint); } else if (mProgress < 300L) { canvas.drawBitmap(mHelicopter2, mX - mRadius, mY - mRadius, paint); } else if(mProgress < 400L) { canvas.drawBitmap(mHelicopter3, mX - mRadius, mY - mRadius, paint); } } public boolean done() { return mProgress > 700L; } } private ArrayList<Helicopter> mHelicopters = new ArrayList<Helicopter>(); 2) this is being called in the run() of a thread: private void doDraw(Canvas canvas) { final long now = SystemClock.elapsedRealtime(); canvas.save(); for (int i = 0; i < mHelicopters.size(); i++) { final Helicopter explosion = mHelicopters.get(i); explosion.update(now); } for (int i = 0; i < mHelicopters.size(); i++) { final Helicopter explosion = mHelicopters.get(i); explosion.draw(canvas, mPaint); } canvas.restore(); } can someone help me? i have looked at a lot of the examples on the web on animation, they seem to always involve text, but not images. thanks.

    Read the article

  • android imageview onClickListener animation

    - by Javadid
    hi. I guess this is kind of a idiotic question but i have tried setting onClicklistener on an ImageView and it has worked. But the problem is that the user cannot sense the click. I mean if some of u have worked on other mobile environs(like apple iphone) then wen we click on a Image in other environs then it gives an effect on the image so that the user can understand that the image has been clicked. I have tried setting alpha using "setalpha" method but it doesnt work. Though the same thing is working fine on onFocusListener implementation. Can some1 suggest a different way to modify the image on click... I am new to android so havent learnt the nuances of simple animation also... if there is any simple animation i can use for the same then plzz plzzz let me know... Thanx...

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >