ccsprite texture slide - objective-c

Is their any way to change the color of a ccsprite from one end of the sprite to the other smoothly within a precise time frame. I am trying to implement a smoothly moving torchlight effect on tiles.
Thanks.

Related

animate pan gesture

i have wrote a subclass of UIView, which in drawRect: draws itself. it is actually something like day-long timeline for movie - it draws time axis with ticks and time text labels. it can be zoomed in up to seconds and zoomed out up to all 24 hours. when its zoomed in, it could be scrolled with pan gesture. so here is the question: how can i implement simple animation, when the finger is lifted, timeline continues to scroll for a while and then stops (with negative acceleration)?
two ideas comes to my mind:
implement animation by myself using another thread
make new class - a subclass of CALayer and then use CABasicAnimation. add this class to the layers of my view. but here i should totally move all my code written for view to new subclass of CALayer, what i dont want to do. would it be ok?
any other ideas?
Wouldn't it be easier to integrate the view in a UIScrollView, let that handle the scrolling and zooming and let your class just do the drawing?

Scrolling Scene in cocos2d

I have a sprite which moves across the screen.so i want to switch between the scenes.how can i do that.i am not interested in using Tile Map.I want just like angry birds scene scrolling.
Any Idea,
Thanks
If i understand what your asking you could just add everything to a cclayer and have everything as a child of it and move the full layer left or right to scroll
As glogic says, create a CCLayer and then add a CCSprite to it with an image much larger than the screen size.
Now in your touch handling code, do something like this...
OnTouchBegin - store position of the touch
OnTouchMoved - calculate distance from stored position where touch started and move the whole layer by that much.
OnTouchEnd - If your sprite has move too far and you have gone off the edge of the sprite, slide it back to the edge

Animating an MKOverlayView

I have an MKOverlayView that displays animated radar data as a series of images. The issue I have is that the radar images are chopped into tiles by MapKit. To swap images I have a timer that calls an update function which sets the current image in my overlay and then calls the following
[myRadarOverlayView setNeedsDisplayInMapRect:self.mapView.visibleMapRect];
The overlay updates, but does so one tile at a time so I get a choppy animation. Any ideas about how make all the tiles animate (i.e. swap images) at the exact same time?
I solved this by adding a UIImageView as a subview of the MKOverlayView.
To animate, stop drawing with the
normal
drawMapRect:zoomScale:inContext: (via
an instance variable/property flag) and
draw to the UIImageView instead (to
the animationImages property), then
use startAnimating.
You can handle panning and zooming by
reinitializing the UIImageView in
response to
mapView:regionDidChangeAnimated:.
Sample code how to animate a circle:
http://yickhong-ios.blogspot.com/2012/04/animated-circle-on-mkmapview.html
Is there a callback when all the tiles have finished loading? If so, you could go with double buffering, and update the view offscreen, and then switch it in.

How to keep an object in view of a scrollview while animation moves the object offscreen

Good day all;
I have an UIImageView that I animate around a large UIView. The UIView is contained within a UIScrollView.
Now, with small movement animations of the UIImageView within the UIView, if it passes a certain thresh hold (gets close to the edge of the screen), I will manually scroll the UIScrollView to re-center the UIImageView. The code is synchronous in that I animate the UIImageView and then scroll to point in the UIScrollView.
Where I am having an issue is when there is a really long movement animation, the entire scrolling process struggles and I get a lot of skipped frames. I am not certain bit I think it is due to my synchronous code and I believe I need a way to execute the scrolling and the animation at the same time but I have no idea how to do it.
Is there a way to make the scrollview listen to where the UIImageView is at all times and center it when it passes a thresh hold even when in the middle of executing an animation?
By the way, I have disabled the user from scrolling the UIScrollView.
Thanks in advance.
Sorry I have left this for so long, I actually solved this a long time ago but forgot to post my solution.
Basically, pass the UIScrollview to the animated object (a layer or view). The animated object will have itself as a delegate for the animation and implement the methond "animationDidStart:(CAAnimation *)theAnimation".
If you persist the destination location in the animated object and the UIScrollView, then you can compute where to move the scrollview in the "animationDidStart" method.
Beware that the content offset and you destination location in the scrollview must be scaled if your scollview has been scaled. (Trap for young players)

Animate the drawing of a line (Quartz 2D?)

How would you go about animating the drawing of a line in a UIView on the iPhone? Is this possible? It can be drawn but can it easily be animated so it appears to be hand drawn?
There's no built-in way to do this no. You'd have to redraw the line repeatedly, interpolating between the start and end points using a timer callback to invalidate the view and trigger a redraw. Of course the redraw would have to draw everything in the area of the view bring redrawn which is potentially slow.
What I would do if I had a series of lines I wanted to draw over a period of time is to have two subviews - they would cover the same area and the top one would have a transparent background. Have the top one draw just the line that I am currently animating and when it's finished, draw the full length of it in the lower view. Then repeat, animating the next line in the top view.
With the new API you can do that easily, using strokeEnd property of CGPath.
You can read more details here: What's the easiest way to animate a line?