swift - How do I change a tile to another (or a blank) in SpriteKit? -


so i'm trying program chess app in xcode 8.3.3 using tile map node, 8x8 tile map containing either piece or blank space per tile (made in gamescene.sks, not code). want change tile. example, if moves pawn, want change starting space pawn blank space , change ending square blank space pawn. tile groups in file called pieces.sks, made @ file->new->file->spritekit tile set. here's have far in gamescene.swift (i took out things not relating question), goal change single square white bishop when code run:

class gamescene: skscene {      var pieces : sktilemapnode?      override func didmove(to view: skview) {          self.pieces = self.childnode(withname: "//pieces") as? sktilemapnode          if let pieces = self.pieces {             pieces.settilegroup(backgroundgroup*, forcolumn: 4, row: 4) //arbitrary square i'm using testing         }     }     } 

so pieces.settilegroup confuses me few reasons, such "forcolumn" instead of simple "column". got off apple developer documentation, , not sure right thing want. backgroundgroup (starred in code) argument placeholder. have no idea how fill in white bishop there. thanks!

i found answer @ https://www.raywenderlich.com/137216/whats-new-spritekit-ios-10-look-tile-maps incredibly useful tile maps in general.

i added:

let tileset = sktileset(named: "pieces")  pieces.settilegroup(tileset?.tilegroups[0], forcolumn: 4, row: 4) 

origin in bottom left, standard cartesian plane's first quadrant.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -