ios - Getting custom class property from contact.bodyA.node -


i developing ios game , having issue didbegincontact().

i trying .difference property 1 of custom classes, "fullbarclass". here code:

func didbegincontact(contact: skphysicscontact) {     var a: skphysicsbody     var b: skphysicsbody      if contact.bodya.categorybitmask < contact.bodyb.categorybitmask{         = contact.bodya         b = contact.bodyb     } else {         b = contact.bodya         = contact.bodyb     }      let bar : fullbarclass = contact.bodya.node     let dif = int(bar.difference)     println(dif) } 

on "let bar : ..." line, getting error: "sknode? not convertible 'fullbarclass' ".

does know why not working?

since contact.bodya.node optional and may not fullbarclass, can't assign body node object fullbarclass constant. can conditionally assign object bar if it's appropriate type by

if let bar = contact.bodya.node as? fullbarclass {    // execute if body node fullbarclass    let dif = int(bar.difference)    print(dif) } 

Comments

Popular posts from this blog

Upgrade php version of xampp not success -

amazon web services - S3 and apache mod_proxy with basic authentication -

powershell - This solution contains one or more assemblies targeted for the global assembly cache -