spriteFrameByName() doesn't work?

I wrote the lua script like this…

playerSprite= cocos2d.CCSprite:spriteWithSpriteFrameName("player_walk_front_4.png")
playerSprite:setPosition(cocos2d.CCPoint(140, winSize.height/4*3))
layerTitle:addChild(playerSprite)

animFrames = cocos2d.CCMutableArray_CCSpriteFrame__:new(6)

for i = 0, 5 do
    spriteFrameCache = cocos2d.CCSpriteFrameCache:sharedSpriteFrameCache()
    spriteFrame = cache.spriteFrameByName( string.format('%s%d%s', "player_walk_front_", i, ".png") )
    animFrames.addObject(spriteFrame)
end

animation = cocos2d.CCAnimation:animationWithFrames(animFrames, 0.5)
animate = cocos2d.CCAnimate:actionWithAnimation(animation, false)
playerSprite:runAction(cocos2d.CCRepeatForever:actionWithAction(animate))

but it cause the error.
in [animFrame.addObject(spriteFrame)] frame is just null…

what am I doing wrong??

spriteFrame = cache:spriteFrameByName( string.format('%s%d%s', "player_walk_front_", i, ".png") )
animFrames:addObject(spriteFrame)

YuLei Liao wrote:

[…]

Thank you :slight_smile: