This issue gave me a lot of headache, so just want to share it with you. If may help you, I will be more then happy 😉
I have a large parallax background and just wanted to animate one spot on my map. What I needed you can see in iUridium video at this link (blinking hatch on Dreadnought map for spawning Torpedos). What I’ve used are Tiled and Zwoptex tools, but I can assume using other tools should make not much difference. In this procedure I asume you are familiar with these tools. So, what I did is as follows:
1. First, I have used some graphical editor and created animated frames (images) for the blinking hatch (actually, just changed the hatch color)
2. Then, I have used Zwoptex to create Texture Atlas containing animated frames (saved it as “blinkframes.plist”)
3. Using Tiled I created new Tileset with newly made Texture Atlas
4. I have created new Tilemap layer (let us call it “Blink”)
5. I selected initial image from my new Tileset and put it on new Layer on position where blinking hatch should appear
6. The most important, I have used following code to load Texture Atlas:
-
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:
-
@"blinkframes.plist" texture:[tileMap layerNamed:@"Blink"].texture];
7. For animation, I have used standard way to animate hatch on my map (of course, do not forget to use SpriteFrames from Texture Atlas):
-
float animationSpeed = 0.25;
-
NSMutableArray *animationArray = [NSMutableArray array];
-
-
[animationArray addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"blink1.png"]];
-
[animationArray addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"blink2.png"]];
-
[animationArray addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"blink3.png"]];
-
-
CCAnimation *animation = [CCAnimation animationWithName:@"animation" delay:animationSpeed frames:animationArray];
-
CCAction *action = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:animation restoreOriginalFrame:NO]];
-
-
CCTMXLayer *layer = [tileMap layerNamed:@"Blink"];
-
CGPoint position = CGPointMake(9.0f, 8.0f);
-
-
CCSprite *tile = (CCSprite*) [layer tileAt:position];
-
[tile runAction:action];
And, that’s it. I hope I was clear enough in this post, if not feel free to comment it.
Hi, congratulations too this page owner. It’s great.
YMMD with that awnesr! TX
Great post.
Suggestion:
Can you make another tutorial explaining how to make a wheel of fortune (a rotary picker/chooser)?
like this:
http://goo.gl/WPJLe
Thanks!!
Much appreciated for the information and share!
Greetings! Extremely beneficial assistance on this short article! It truly is the small modifications that make the greatest adjustments. Many thanks a whole lot for sharing!
Outstanding post however I was wondering if you could write a litte more on this topic? I’d be very thankful if you could elaborate a little bit further. Cheers!
Very interesting info!Perfect just what I was searching for!
Hi! I could have sworn I’ve been to this website before but after reading through some of the post I realized it’s new to me. Nonetheless, I’m definitely glad I found it and I’ll be book-marking and checking back often!
Very nice tips…