this is lua code
testSprite(sceneGame,"soldier.plist", "soldier.png", "S_Walk%02d.png", 6, 420, 320, 1, true)
testSprite(sceneGame,"helicopter.plist", "helicopter.png", "H_Walk%02d.png", 6, 480, 320, 0.5, false)
function testSprite(parent, plist, png, param, total, posx, posy, vertexz, shader)
local cache = CCSpriteFrameCache:sharedSpriteFrameCache()
cache:addSpriteFramesWithFile(plist)
local spritebatch = CCSpriteBatchNode:create(png)
parent:addChild(spritebatch)
local m_pSprite = CCSprite:createWithSpriteFrameName( string.format(param, 0))
if shader == true then
spritebatch:setShaderProgram(CCShaderCache:sharedShaderCache():programForKey( 'ShaderPositionTextureColorAlphaTest' ));
spritebatch:getShaderProgram():setUniformLocationWith1f(spritebatch:getUniformLocation("CC_alpha_value"), 0)
end
m_pSprite:setPosition(posx,posy)
spritebatch:addChild(m_pSprite)
m_pSprite:setVertexZ(vertexz)
local animFrames = CCArray:createWithCapacity(total)
for i = 0,total-1 do
local frame = cache:spriteFrameByName( string.format(param, i) )
assert(frame ~= nil, string.format(param, i))
animFrames:addObject(frame)
end
local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.05)
m_pSprite:runAction( CCRepeatForever:create( CCAnimate:create(animation) ) )
end
and it become this: see pic 1
but what i want is this: see pic 2
and I just modify this
testSprite(sceneGame,"helicopter.plist", "helicopter.png", "H_Walk%02d.png", 6, 480, 320, 0.5, false)
testSprite(sceneGame,"soldier.plist", "soldier.png", "S_Walk%02d.png", 6, 420, 320, 1, true)
20130606233232.jpg (22.6 KB)
20130606233824.jpg (17.0 KB)