I m trying to create a game using sprite builder and swift. In the game the player can change, for example the shoes of a baby in center of the screen and in the left of the screen there are different kinds of shoes wich the player can choose from. In spritebuilder i put 3 color nodes with names of colorNode , colornode1, centroNode. I would like to put the colornode in the position of centronode, one by one. Thanks Here there is the code i've Tried to write :
class MainScene: CCNode {
let colorNode : CCNodeColor!
let colorNode1 : CCNodeColor!
weak var centroNode : CCNodeColor!
init (centroNode:CCNodeColor){
self.centroNode=centroNode
}
override func onEnter() {
super.onEnter()
self.userInteractionEnabled = true
}
override func touchBegan(touch: CCTouch!, withEvent event: CCTouchEvent!) {
let touchPosition = touch.locationInNode(self)
if(CGRectContainsPoint(colorNode.boundingBox(), touchPosition))
{
print("entratooo")
centroNode=colorNode
print("centroooo")
let move = CCActionMoveTo(duration:1.0, position:ccp(20, 100))
centroNode.runAction(move)
}
else {print ("toccooo")}
if(CGRectContainsPoint(colorNode1.boundingBox(), touchPosition))
{
print("entratooo22")
Given the provided error message
It looks like you just need to add an initializer with 0 params to your class