You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe this is not properly a bug or issue, but an improve.
Suppose we have a layer in our map that represent a wall, composed by little rectangles with a texture, and we have this code to get the layer:
So, if you have a layer composed by many rectangle with textures around your map, this physicsBody cover only the bounding rectangle of your map.
That's not enough.
Now we suppose that a normal user set all tiles of his wall with the property string "wall", we can obtain the array of tiles that composed all the wall layer with :
self.wallsTiles = wallsTilesLayer.getTilesWithProperty("wall", "" as AnyObject)
One of the immediate error we can do is to create a physicsBody for each tile of the array, something like:
for wallTile in wallsTiles {
wallTile.setupPhysics(isDynamic:false)
}
This work , but it generate a giant amount of physics bodies to check and this drop your FPS.
A good thing to avoid this problem could be make an array of SKPhysicsBodies:
var wallBodies = [SKPhysicsBody]()
for wallTile in wallsTiles {
let wallBody = SKPhysicsBody.init(edgeLoopFrom: wallTile.frame)
wallBody.isDynamic = false
wallBodies.append(wallBody)
}
let wall = SKPhysicsBody.init(bodies: wallBodies)
self.wallsTilesLayer.physicsBody = wall
I don't know if your function was an error but I just want to report my idea to improve the physics.
The text was updated successfully, but these errors were encountered:
That method is a leftover from a really old feature request. The idea was to allow users bypass Apple's clunky sks editor and quickly prototype shapes & dynamics in Tiled for SpriteKit...even if no tiles are being drawn. I thought it might be a fun exercise to expand the API to accommodate this, so I created a few proof of concepts (one of which is shown here). I believe that function has been renamed setupLayerPhysicsBoundary in my development branch, so I'll be sure to update that for the next release.
Right now the methods for adding physics to tiles & objects are fairly rudimentary; I'm not opposed to adding more dynamics features, but I also don't want to go to far down a path of adding custom features that users will be implementing themselves.
The next update has support for tile objects and (hopefully) objects created via the tile collision editor. I'm happy to entertain any ideas you have beyond that.
Maybe this is not properly a bug or issue, but an improve.
Suppose we have a layer in our map that represent a wall, composed by little rectangles with a texture, and we have this code to get the layer:
self.wallsTilesLayer = self.tilemap.getLayer(named: "walls") as! SKTileLayer
Now to get the physicsBody we can do:
self.wallsTilesLayer.setPhysicsBody()
that call this method of your framework:
So, if you have a layer composed by many rectangle with textures around your map, this physicsBody cover only the bounding rectangle of your map.
That's not enough.
Now we suppose that a normal user set all tiles of his wall with the property string "wall", we can obtain the array of tiles that composed all the wall layer with :
self.wallsTiles = wallsTilesLayer.getTilesWithProperty("wall", "" as AnyObject)
One of the immediate error we can do is to create a physicsBody for each tile of the array, something like:
This work , but it generate a giant amount of physics bodies to check and this drop your FPS.
A good thing to avoid this problem could be make an array of SKPhysicsBodies:
I don't know if your function was an error but I just want to report my idea to improve the physics.
The text was updated successfully, but these errors were encountered: