2017-04-17 6 views
1

voulez faire une application comme Paper.io. J'ai été en mesure de faire l'application pour tracer une ligne le long de son chemin. mais n'a pas pu créer un chemin fermé.Remplissez la couleur dans la forme comme Paper.io

func action() 
    { 
    var action = SKAction() 
    switch direction { 
    case 1: 
     action = SKAction.moveBy(x:164,y:0,duration:0.6) 
    case -1: 
     action = SKAction.moveBy(x:-164,y:0,duration:0.6) 
    case 2: 
     action = SKAction.moveBy(x:0,y:164,duration:0.6) 
    case -2: 
     action = SKAction.moveBy(x:0,y:-164,duration:0.6) 


    default: 
     return 
    } 

    print("touch start ",posx,posy) 

    var repeatAction = SKAction.repeatForever(action) 

    ball.run(repeatAction, withKey: "Moving") 

    } 

Répondre

0

Je crois que vous devez créer un objet CGPath aux côtés du mouvement. Vous pouvez ensuite utiliser ce chemin pour créer SKShapeNode qui a une propriété fillColor.

let path = CGMutablePath() 
// Construct the path e.g. using path.addLine(point:transform:) 

let shape = SKShapeNode(path: path) 
shape.fillColor = .blue