sktilemapnode

Connect Physicsbodies on TileMap in SpriteKit

给你一囗甜甜゛ 提交于 2019-12-23 01:45:23
问题 I use the following function to append physicsbodies on tiles from a SKTileMapNode: static func addPhysicsBody(to tileMap: SKTileMapNode, and tileInfo: String){ let tileSize = tileMap.tileSize let halfWidth = CGFloat(tileMap.numberOfColumns) / 2 * tileSize.width let halfHeight = CGFloat(tileMap.numberOfRows) / 2 * tileSize.height for row in 0..<tileMap.numberOfColumns{ for column in 0..<tileMap.numberOfRows{ let tileDefinition = tileMap.tileDefinition(atColumn: column, row: row) let

What is the proper way to programmatically create a SpriteKit SKTileMap?

一曲冷凌霜 提交于 2019-12-18 17:08:25
问题 I am creating a tile map for an iOS game I am working on. The map is a top down view of an island. Most of the tiles are water, but some are land. The water tile is reused to create the water, but none of the land tiles are used more than once, because all of the land tiles are unique. I have looked through the docs for SKTileDefinition, SKTileGroup, SKTileGroupRule, SKTileSet, and SKTileMap, and this is what I came up with: func createTileMap() { let waterTile = SKTileDefinition(texture:

Programmatically creating an SKTileDefinition

一个人想着一个人 提交于 2019-12-11 04:24:50
问题 I've been beating my head against a wall for hours now. I am trying to modify a texture inside my app using a CIFilter and then use that new texture as a part of a new SKTileDefinition to recolor tiles on my map. The function bellow finds tiles that players "own" and attempts to recolor them by changing the SKTileDefinition to the coloredDefinition . func updateMapTileColoration(for players: Array<Player>){ for player in players { for row in 0..<mainBoardMap!.numberOfRows { for col in 0..

Giving physics to tiles of SKTileMapNode in Xcode 8

筅森魡賤 提交于 2019-12-04 13:06:42
问题 I am learning Swift, and as a project I am working on a tile based 2D game similar to super mario where my character will walk and jump on tiles. The latest version of Xcode and Sprite Kit give the ability to create a Tile Map directly in Xcode. In the presentation of the new Xcode and Sprite kit, the guy demonstrates a game similar to what i am working on. https://developer.apple.com/videos/play/wwdc2016/610/ (around the 20th minute). He mentions giving Tiles user data properties which i did

SpriteKit Memory leaks changing Scenes containing SKTileMapNodes

戏子无情 提交于 2019-12-03 14:15:30
问题 I am trying to create a simple 2d platform game using Swift, SpriteKit, and SKTileMaps. But every time i change between scenes containing SKTileMaps I see a lot of memory leaks in the Xcode Instruments. I have recreated the problem as simple as I can. I am using a .sks file to create the scene and this file only contains 1 tileMap filled with some tiles. The code in the view controller for presenting the scene: if let view = self.view as! SKView? { let scene = LoadingScene(size: CGSize(width:

Giving physics to tiles of SKTileMapNode in Xcode 8

半腔热情 提交于 2019-12-03 08:21:23
I am learning Swift, and as a project I am working on a tile based 2D game similar to super mario where my character will walk and jump on tiles. The latest version of Xcode and Sprite Kit give the ability to create a Tile Map directly in Xcode. In the presentation of the new Xcode and Sprite kit, the guy demonstrates a game similar to what i am working on. https://developer.apple.com/videos/play/wwdc2016/610/ (around the 20th minute). He mentions giving Tiles user data properties which i did, and in code we search through all the tiles which have that user data and give them some physics

SpriteKit Memory leaks changing Scenes containing SKTileMapNodes

末鹿安然 提交于 2019-12-03 04:06:07
I am trying to create a simple 2d platform game using Swift, SpriteKit, and SKTileMaps. But every time i change between scenes containing SKTileMaps I see a lot of memory leaks in the Xcode Instruments. I have recreated the problem as simple as I can. I am using a .sks file to create the scene and this file only contains 1 tileMap filled with some tiles. The code in the view controller for presenting the scene: if let view = self.view as! SKView? { let scene = LoadingScene(size: CGSize(width: 2048, height: 1536)) scene.scaleMode = .aspectFill view.presentScene(scene) The code for the scene:

Programmatically create SKTileMapNode in Swift

人走茶凉 提交于 2019-11-30 21:58:32
does anyone know how to create an SKTileMapNode programmatically using Swift please? (NOTE: I do not want to do this using the editor, I want to achieve this programmatically only) I have tried the following but does not render my tile map let bgTexture = SKTexture(imageNamed: "background") let bgDefinition = SKTileDefinition(texture: bgTexture, size: bgTexture.size()) let bgGroup = SKTileGroup(tileDefinition: bgDefinition) let tileSet = SKTileSet(tileGroups: [bgGroup]) let bgNode = SKTileMapNode(tileSet: tileSet, columns: 5, rows: 5, tileSize: bgTexture.size()) bgNode.position = CGPoint(x:

What is the proper way to programmatically create a SpriteKit SKTileMap?

不打扰是莪最后的温柔 提交于 2019-11-30 15:57:30
I am creating a tile map for an iOS game I am working on. The map is a top down view of an island. Most of the tiles are water, but some are land. The water tile is reused to create the water, but none of the land tiles are used more than once, because all of the land tiles are unique. I have looked through the docs for SKTileDefinition, SKTileGroup, SKTileGroupRule, SKTileSet, and SKTileMap, and this is what I came up with: func createTileMap() { let waterTile = SKTileDefinition(texture: SKTexture(imageNamed: "map-tile-1")) let waterTileGroup = SKTileGroup(tileDefinition: waterTile) let

Programmatically create SKTileMapNode in Swift

不羁的心 提交于 2019-11-29 22:24:22
问题 does anyone know how to create an SKTileMapNode programmatically using Swift please? (NOTE: I do not want to do this using the editor, I want to achieve this programmatically only) I have tried the following but does not render my tile map let bgTexture = SKTexture(imageNamed: "background") let bgDefinition = SKTileDefinition(texture: bgTexture, size: bgTexture.size()) let bgGroup = SKTileGroup(tileDefinition: bgDefinition) let tileSet = SKTileSet(tileGroups: [bgGroup]) let bgNode =