sprite kit - Compiler issues with Swift 1.2 / Xcode 6.3 -
i’m trying create game swift , have bug can’t figure how fix :
collisionwithbullet(firstbody.node skspritenode, bullet: secondbody.node skspritenode) } else if ((firstbody.categorybitmask == physicscategory.enemy) && (secondbody.categorybitmask == physicscategory.player) || (firstbody.categorybitmask == physicscategory.player) && (secondbody.categorybitmask == physicscategory.enemy)){ collisionwithperson(firstbody.node skspritenode , person: secondbody.node skspritenode) collisionwithbullet(firstbody.node skspritenode, bullet: secondbody.node skspritenode) i got following message:
'sknode?' not convertible 'skspritenode'; did mean use 'as!' force downcast.
i have searched on several website solution , have tried change as as! , as? nothing works.
i thank in advance help
this means 1 of sprites initialized sknodes meant hold skspritenodes.
you tried downcast skspritenode not supposed not meant display images.
the fix initialize them skspritenodes instead of sknode.
from apple documentation
the sknode class fundamental building block of sprite kit content. sknode class doesn’t draw visual content. primary role provide baseline behavior other node classes use. visual elements in sprite kit-based game drawn using predefined sknode subclasses.
Comments
Post a Comment