Jump to content

Search the Community

Showing results for tags 'puttile'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 3 results

  1. Hello ! I'm new with Phaser and I have some issue whem I want to fill a tilemap with 2 types of tile. var TILE_SIZE = 20;var map;var layer;var player;var game = new Phaser.Game(600, 600, Phaser.AUTO, 'Fill Zone', { preload: preload, create: create, update: update });function preload(){ map = game.add.tilemap(); game.load.image("wng", "img/wng.png");}function create(){ map.addTilesetImage('tiles', "wng"); layer = map.create('Tile Layer 1', 10, 10, TILE_SIZE, TILE_SIZE); layer.resizeWorld(); for(var i = 0; i < 20; i++){ for(var j = 0; j < 20; j++){ map.putTile(0,1,j,layer);//Index 0 works each time } } map.putTile(1,3,3,layer);//Index 1 never works Throw : Uncaught TypeError: Cannot read property '2' of undefined }This is the version I actually have. This code not works when it comes to create the second type of tile. You may say try with 2 different tiles and not a spritesheet. I also did this : var TILE_SIZE = 20;var map;var layer;var player;var game = new Phaser.Game(600, 600, Phaser.AUTO, 'Fill Zone', { preload: preload, create: create, update: update });function preload(){ map = game.add.tilemap(); game.load.image("wall", "img/wall.png"); game.load.image("ground", "img/ground.png");} function create(){ map.addTilesetImage('wall'); map.addTilesetImage('ground'); layer = map.create('Tile Layer 1', 10, 10, TILE_SIZE, TILE_SIZE); layer.resizeWorld(); for(var i = 0; i < 20; i++){ for(var j = 0; j < 20; j++){ map.putTile(0,1,j,layer);//Work } } map.putTile(1,3,3,layer);//Don't work Throw : Uncaught TypeError: Cannot read property '2' of undefined }I have exactly the same error ! Uncaught TypeError: Cannot read property '2' of undefined I thing it's a problem with the tile's index but I don't know how to access it. Create instances for each tile may be a solution two, but I didn't found how to do in the doc. Here is a link if you want to check the code : http://poillic.com/games/phaser Hope you can help me with this hell.
  2. Greetings!!! It's my first time here. So, my problem is, when I use map.putTile, I set the collidable tiles using map.setCollisionByExclusion([6]), but it's not working. Let me show a piece of code here: game.physics.startSystem(Phaser.Physics.ARCADE); mapa = MapGen.gerarMapa([0, 50, 50, 45, 5, 0, 5]); game.stage.backgroundColor = '#2d2d2d'; map = game.add.tilemap(); map.addTilesetImage('dungeon'); layer = map.create('mapa', 50, 50, 32, 32); for (var x = mapa.length; x-- { for (var y = mapa[x].length; y-- { if (mapa[x][y] == '.') { map.putTile(6, x, y, layer); } else { map.putTile(14, x, y, layer); } } } layer.resizeWorld(); map.setCollisionByExclusion([6]); personagem = game.add.sprite(100, 82, 'personagem'); game.physics.enable(personagem); personagem.body.setSize(50, 41, 25, 20); personagem.body.collideWorldBounds = true;This code is in my create function, so, basically, I generate my map using "MapGen.gerarMapa([0, 50, 50, 45, 5, 0, 5]);" and I'm using "map.putTile(6, x, y, layer);" to put the floor, and "map.putTile(14, x, y, layer);" to put the wall, then I say that the just the tile 6 won't collide using "map.setCollisionByExclusion([6]);". That's it, if anyone can help me solve this problem I would be very grateful.
  3. Good evening all, I am trying to use putTile to generate a tilemap. Unfortunately, whenever, I try and create a tile somewhere other than at x = 1, y = 1, the tile does not appear. I'm using Phaser 2.0.5 and the Ninja tileset, though for this example I've not yet added physics. Note that although I try and create a tile at 1, 1 and one at 1, 2, only one tile appears. I've tried tweaking with the parameters a few different ways to no avail. Thanks in advance! <!DOCTYPE html><html> <head> <title>Tile Example</title> <script src="/javascripts/lib/phaser.js"></script> <script> var game = new Phaser.Game(800, 600, Phaser.AUTO, 'game-container', { preload: preload, create: create, update: update }); function preload(game) { var me = this; me.game.load.image('collision', '/assets/tilemaps/tiles/ninja-tiles32.png'); } function create() { var me = this; me.map = me.game.add.tilemap(); me.map.addTilesetImage('collision', 'collision', 32, 32, 0, 0); me.collisionLayer = me.map.createBlankLayer('collision', 16, 16, 32, 32); me.collisionLayer.visible = true; me.map.putTile(1, 1, 1, 'collision'); me.map.putTile(1, 1, 2, 'collision'); me.collisionLayer.resizeWorld(); } function update() { var me = this; } </script> </head> <body> </body></html>
×
×
  • Create New...