标签:
local spriteFrameCache= cc.SpriteFrameCache:getInstance();
local animationCache= cc.AnimationCache:getInstance();
spriteFrameCache:addSpriteFrames("Effect/loading.plist");animationCache :addAnimations ("Effect/loading_effect.plist");
local animation_loading= cc.AnimationCache:getInstance():getAnimation("animation_loading")
self.animationLoading = cc.Sprite:create();
self.animationLoading:setPosition( cc.p(viewSize.width/2, viewSize.height/2));
self.Layer :addChild ( self.animationLoading);
self.animationLoading:runAction( cc.RepeatForever:create(cc.Animate:create(animation_loading) ) );
--方法2
--[[local spriteFrameCache= cc.SpriteFrameCache:getInstance();
spriteFrameCache:addSpriteFrames("Effect/loading.plist","Effect/loading.png");
self.animationLoading = cc.Sprite:create();
self.animationLoading:setPosition( cc.p(viewSize.width/2, viewSize.height/2));
self.Layer :addChild ( self.animationLoading);]]
------------------------------
loading_effect.plist文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>animations</key>
<dict>
<!-- Loading特效 -->
<key>animation_loading</key>
<dict>
<key>delay</key>
<real>0.03</real>
<key>frames</key>
<array>
<string>loading_000.png</string>
<string>loading_001.png</string>
....
<string>loading_059.png</string>
</array>
</dict>
</dict>
</dict>
</plist>
------------------------------
loading_.plist文件
<?xml version="1.0" encoding="UTF-8"?>......................
<key>loading_059.png</key>
<dict>
<key>frame</key>
<string>{{508,84},{1,1}}</string>
<key>offset</key>
<string>{-99.5,99.5}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{1,1}}</string>
<key>sourceSize</key>
<string>{200,200}</string>
</dict>
</dict>
<key>metadata</key>
<dict>
<key>format</key>
<integer>2</integer>
<key>realTextureFileName</key>
<string>loading.png</string>
<key>size</key>
<string>{512,512}</string>
<key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:0e9839b17b099fb41aef47a1984b0b09$</string>
<key>textureFileName</key>
<string>loading.png</string>
</dict>
</dict>
</plist>
loading.plist
loading.png
用TexturePackerGUI工具生成的
标签:
原文地址:http://blog.csdn.net/qq_24550675/article/details/51353317