I used below code to create sprite in swift.
var bg : CCSprite = CCSprite.spriteWithImageNamed("Default.png");
bg.position = ccp(SW*0.5, SH*0.5)
self.addChild(bg)
Please check image, its giving error for 1st line.
Error : Type 'AnyObject' cannot be implicitly downcast to 'CCNode': did you mean to use 'as' to force downcast?
Is there any Cocos2d-Swift documents online ?
Just rewrite
as
Swift does not implicitly convert (in this case:
AnyObject!
toCCSprite
), you have to add an explicit cast withas
.