0

I've been using JSTileMap to process TMX tile maps in my game, and so far, naturally - i used only square tiles (example in the image attached).

However, i wanted to use ramp-style tiles (also example in the image), which are triangles, and so far - i did not find a way for the game to treat them as triangles (the bounds given to the tiles are squared and obviously that doesnt fit a ramp-style tile).

How do i do this? is it possible with JSTileMap? any other external library? or it must involve specific attention of (as described in here , sort of)

Thanks!

tile example

Community
  • 1
  • 1
Zephyer
  • 333
  • 6
  • 16
  • i dont really understand the downvotes. this is probably a question that every beginner game developer asks himself. would love comments instead of rank changes. – Zephyer Jun 20 '14 at 08:38

2 Answers2

2

There are no "triangle" tiles in any tilebased renderer. The gray area in the image simply needs to be transparent. As for collision handling, that's something you need to handle in code based on the tile GID.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • thank you. would that make sense to put the 'triangle tiles' in a separate layer in the TMX? (to make it easy to work on them) – Zephyer Jun 20 '14 at 08:41
  • No, not really. You shouldn't layer for specific tiles in the tilemap but for specific purposes (ie collision, foreground, background, etc). – CodeSmile Jun 20 '14 at 10:13
0

This is my solution:

in a Gid example:

             case 455: //example gid code
                    //slide to left
                    node!.name = "rampLeft1"
                    let path: CGMutablePathRef = CGPathCreateMutable()
                    CGPathMoveToPoint(path, nil, 0 , 0 )
                    CGPathAddLineToPoint(path, nil, 64 , 64 )//tilesize 64x64
                    CGPathAddLineToPoint(path, nil, 64 , 0 )
                    CGPathAddLineToPoint(path, nil, 0 , 0 )
                    CGPathCloseSubpath(path)

                    //example view
                    var llshape = SKShapeNode(path: path)
                    llshape.position = node!.position
                    llshape.zPosition = 30
                    addChild(llshape)


                    node.physicsBody = SKPhysicsBody(polygonFromPath: path)
                    node.physicsBody?.dynamic = false
                    node.physicsBody?.allowsRotation=false
                    node.physicsBody?.affectedByGravity = false
                    node.physicsBody?.friction = 0.1
Opal
  • 81,889
  • 28
  • 189
  • 210