Search the Community

Showing results for tags 'tiled'.



More search options

  • 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 Platform
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

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 202 results

  1. Hi everyone, Anyone knows how i could convert a object layer from tiled(with rectangle, circle...) into a P2 object/sprite or whatever ? I would like that my player can check if there's an overlap with theses objects :/
  2. I am working on a robot game and I am using phaser library. My requirement is to pass the x y coordinates to robot(sprites) and it should move according to that coordinates without any velocity or speed. Every one is using speed to move the sprite. So, kindly give me some suggestions. Now I am using following code for moving sprites: // The following code is for the robot movement // This is initial velocity player.body.velocity.x = 0; player.body.velocity.y = 0; if (cursors.left.isDown) { player.body.velocity.x = -200; } else if (cursors.right.isDown) { player.body.velocity.x = 200; } if (cursors.up.isDown) { player.body.velocity.y = -200; } else if (cursors.down.isDown) { player.body.velocity.y = 200; }
  3. Hello everyone, I am new to phaser framework. I am working on a game where I am getting a coordinates for sprites through . The problem is how can I update my sprite according to incoming coordinates? ws.onmessage = function(event) { var mySpan = document.getElementById("messageGoesHere"); var mySpan2 = document.getElementById("messageGoesHere2"); var str = event.data; var array = str.split('|'); mySpan.innerHTML = parseInt(array[2]) mySpan2.innerHTML = parseInt(array[3]); x= parseInt(array[2]); y= parseInt(array[3]);
  4. Hi there. I'm an experienced JS dev looking to get into Game Development. I've started out with a fairly small top-down "rpg" style game. I'm used the program "Tiled" to create the world map. So far i've been following this tutorial to get started, learn the basics of Phaser, but now i'm unfortunately running into this problem. This tutorial is about 2 years old, and uses it's own "object" generator, however i'd really like to use Phaser's native `.createFromObjects` function. My code is as follows; this.map = this.game.add.tilemap("world"); this.map.addTilesetImage("sheet", "spritesheet"); let map = this.map; let objects = this.game.add.group(); objects.enableBody = true; this.map.objects.objects.forEach(function(element) { map.createFromObjects(element.name, element.gid, element.properties.sprite, 0, true, false, objects); }); The error I receive in the console; Tilemap.createFromObjects: Invalid objectgroup name given: goldCoins Tilemap.createFromObjects: Invalid objectgroup name given: playerSpawn Tilemap.createFromObjects: Invalid objectgroup name given: goldCoins Tilemap.createFromObjects: Invalid objectgroup name given: campFire Tilemap.createFromObjects: Invalid objectgroup name given: stool Tilemap.createFromObjects: Invalid objectgroup name given: sign I've cut out the majority of the code for sake of saving space in this forum post, but the full code is available here. I've already looked up multiple forum posts, each with their own solutions to fix the bug i'm experiencing, however none have worked. I've tried replacing the "groups" param with the Tiled object's name, as per this post, but i'm unable to find a fix for this. I'd appreciate any help anyone may provide for me.
  5. Hello, I'm new at Phaser and i'm trying to make a map in Tiled and use it in my game, but the collide isn't working. My json Data: "data":[100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 89, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 91, 100, 100, 100, 100, 100, 100, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 86, 86, 86, 86, 86, 86, 86, 86, 86, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 86, 86, 86, 86, 86, 86, 86, 86, 86, 87, 86, 86, 86, 86, 86, 86, 86, 86, 100, 100, 100, 100, 100, 100, 100, 100, 100, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100], map.setCollisionBetween(0, 999, true); Already tyied everything... Any solutions?! Thanks in advance!
  6. Hello, I have a problem with loading JSON file on my game to make a world. This is a files: https://www.sendspace.com/file/icmjbs What is the problem??? How to fix this problem?
  7. I have been playing around with Phaser for a couple of days now, but I have been stuck for like the past 3 days on just trying to set up collision with an object layer I set up in Tiled. I am using Arcade Physics here in the main branch. I tried creating the object layer, like you would with any normal tile layer, but the id is always null and errors out. I then did some research and found out that Phaser doesn't support object layers like that. Some objects (treasure chests) I have created in the object layer show up, however. The problem I am having is making the polylines convert to rigid bodies in order to collide with the player. Update: Right now I am using various hacks to simulate something similar, but the original problem still stands. You can see my code here: https://github.com/damianlajara/interactive-portfolio I also tried using P2 Physics in order to use the method `convertCollisionObjects` to convert the polylines into objects, but that did not work either. You can find the code for that in the P2 branch I have set up. Any help would be greatly appreciated!
  8. bdekk

    Scale tiled map

    Hello everyone. I am trying to load my map made in tiled into my game. However, the map does not scale properly and I cannot see all the objects. Could someone perhaps point me in the right direction? The map does load, it only scales wrong. Shooter.game = new Phaser.Game(window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio, Phaser.AUTO, ''); this.map = this.game.add.tilemap('level3'); //the first parameter is the tileset name as specified in Tiled, the second is the key to the asset this.map.addTilesetImage('tiles_spritesheet', 'gameTiles'); //create layers this.backgroundlayer = this.map.createLayer('background'); this.blockedlayer = this.map.createLayer('blocked'); //collision on blockedLayer this.map.setCollisionBetween(1, 5000, true, 'blocked'); // this.backgroundlayer.scale.set(2); //resizes the game world to match the layer dimensions this.backgroundlayer.wrap = true; this.backgroundlayer.resizeWorld();
  9. This is my first time using both Phaser and Tiled, and it's not going well. When I load my tilemap via: function preload(){ game.load.tilemap('overworld','assets/maps/testmap.json',null, Phaser.Tilemap.TILED_JSON) game.load.image('tiles','assets/maps/testmap.png') } function create(){ var map = game.add.tilemap("overworld") map.addTilesetImage("Dungeon","tiles") var layer = map.createLayer('Ground'); var terrain = map.createLayer('Terrain'); game.layer.resizeWorld(); } Instead of what I see in Tiled: I see: It's hard to tell here, but the dirt stone water etc tiles are all displayed as different grasses. So I tried to do some debugging and made a custom tileset to see exactly how it was going wrong. Here's how it looks in Tiled: and here's how it's rendered by Phaser (with a background color set): As you can see, it's supposed to be 00-09 repeating on the first row, 10-19 repeating on the second etc, but instead displays the first row 5 times and then the second, then back to the first. I don't understand what's going wrong, especially because it's breaking inconsistently using different maps. Any help or insight would be GREATLY appreciated!
  10. Hi there. So currently I have a single player open world game which I am in the process of developing multiplayer for. The current system of map gen is local, and done through a bunch of arrays lol. I chose this route LONG ago, and I know it wasn't the best option, but it was easier for me to throw this together than to learn how to used tiled and object layers etc. Using arrays seemed easier to me because I understood how I can respawn/kill dead objects from the array instead of having to learn tiled's object layer stuff. Anyway, my current system is as follows: At the top of my game basically I have something like this run PS: (The map is 2k x 2k TILES long, each tile is 32x32 so map is 64k x 64k pixels) var mapSize = 2000; var grid = new Array(mapSize).fill(0); for(var i = 0; i<mapSize+1; i++){ grid[i] = new Array(mapSize).fill(0); }; for(var i = 0; i<18000; i++){ var tempX = Math.round(Math.random()*(mapSize-1)); var tempY = Math.round(Math.random()*(mapSize-1)); if(grid[tempX][tempY] == 0){ grid[tempX][tempY] = 2; } } for(var i = 0; i<12000; i++){ var tempX = Math.round(Math.random()*(mapSize-1)); var tempY = Math.round(Math.random()*(mapSize-1)); if(grid[tempX][tempY] == 0){ grid[tempX][tempY] = 3; } } This is an example of how i am generating the map. Basically it creates a 2 dimensional array with values 0, 2, or 3 in this example. My rendering system is shown bellow, basically spawn any non 0 entry within 3k pixels of the person (or 91 tiles) by reading the map array from points based on the players current position: function mapGen(x1, y1, x2, y2){ if(x1<0){ x1 = 0; } else if(x2>(mapSize-1)){ x2 = mapSize-1; } if(y1<0){ y1 = 0; } else if(y2>(mapSize-1)){ y2 = mapSize-1; } for(var row = x1; row<x2; row++){ for(var col = y1; col<y2; col++){ if(grid[row][col]!=0){ temp = position(row, col); if(grid[row][col]==2){ createSprite = itemGroup.create(temp[0], temp[1], 'tree'); createSprite.scale.set(1.1, 1.1); } else if(grid[row][col]==3){ createSprite = itemGroup.create(temp[0], temp[1], 'boulder'); } createSprite.body.immovable = true; } }; }; } This is the render system that is called whenever a player ventures 3k pixels away from a position (The function variables are the corners of the 3k x 3k box around the player in tiles), when called, the position it's using as reference is changed to the current position of the player, so basically it just renders 3k pixels around the player until a player moves to far from that squares center and renders a new one, I do this bc the game cant handle more than a couple thousand sprites on the screen, and doing this lets me have like 200 rendered and have flawless performance. This system works fine for what I need, if there is a 0, leave it blank and the tilesprite background will show, if there is something there then spawn a tree or a rock or whatever said item is (This is just dummy code). For destroying sprites once a player destroys a sprite I get the pixel location of the now dead sprite and change it into tile position and set that tile position to 0. Which is why i chose this system over tiled, it seemed easier to me. Now finally, here is my problem: I have created a lot of the multiplayer aspect, and all the connections and player positions etc. However, the map is still different on every players screen due to the random gen that happens every time game loads. I can create the giant array on the server, however there is no way I can transfer it to the players. Creating the giant array only takes 300ms which is kinda a lot in terms of performance for my game, but if i render it once on the server and send it to every client my server crashes, i assume its because its wayyy too much data or takes too long. I tried writing it out to a file to read then from my clients but that's 11mb lol and I dont know where to smoothly read something like that. So basically, what are my options here. I would be open to switching to tiled, however i dont know how to randomly generate terrain there, and cant do it manually, as well as i like the system I have now bc how easily i can manipulate it. Another solution I have yet to try but I might, is instead of sending the entire map file, just write a file or a variable i could send through sockets with where all the non 0 items are around the array to cut down on space and increase performance. This was kinda poorly written, however I appreciate anyone who took the time to read this, I always chose bad times to write forum posts and right now Im in a rush so I didnt get a chance to re-read this and make myself not sound like I have the English skills of an 8 year old. So if anything needs clarifying let me know! Thanks again for the help.
  11. I have finally finished one of my careers biggest games yet. It's a game meant to showcase the company I work at: Brandlift. It encompasses 1 big world and 9 minigames and 9 playable characters. Be sure to keep music and sound effects on . It has 3 different resolutions: 1920x1080, 1280x720 and 960x540, which is chosen depending on your screens size. Hope you enjoy! http://brandlift-ssl.eu/bl_game/
  12. Working with a friend so, still more less the question can be of sending tiled data between client server through map array would be nice.
  13. There is only one of the coins falling and I don't understand why that is. I looked at the code but I can't seem to figure it out.You will have to reload the page if you miss it ( it is the 5th coin from the left). http://phaser.io/examples/v2/tilemaps/create-from-objects
  14. Hi all, I'm a newbie who just started learning phaser. I have created a tile map with Tiled. It is composed of two tiled layer: background & collision. In collision layer I put some walls. And in the game code, I have loaded tilemaps, create them, and they shows perfectly. Then I set the collision, and sense the collision in update(); I think it should make the sprite collide with wall, but it didn't.. I tried adding "collison" properties in Tiled as I found from some tutorials, but it didn't work either.. Can someone help me? I have my all code & img & json packed here... Thanks~ https://db.tt/AAdpu3zd //load tilemaps in preload. this.load.tilemap('zombieset', 'assets/tilemaps.json', null, Phaser.Tilemap.TILED_JSON); this.load.image('tiles', 'assets/tileset.png'); //start physic systems this.physics.startSystem(Phaser.Physics.ARCADE); //create tiles, and it shows perfectly. this.map = this.add.tilemap('zombieset'); this.map.addTilesetImage('tileset1', 'tiles'); //set collision. this.map.setCollision(1); this.layer = this.map.createLayer('background'); this.layer = this.map.createLayer('collision'); this.layer.resizeWorld(); //sensor collison in update() this.physics.arcade.collide(this.asuna, this.layer);
  15. Hello Everyone, I noticed that tiled allows to save the map file on .js files. I would like to know if it is posible to use them with phaser and if it has advantages over tmx or json files. I'm only going to use the object layers from tiled so Tilemaps are not important for me at the moment. An example of the file generated by tiled: (function(name,data){ if(typeof onTileMapLoaded === 'undefined') { if(typeof TileMaps === 'undefined') TileMaps = {}; TileMaps[name] = data; } else { onTileMapLoaded(name,data); }})("test", { "height":25, "layers":[ { "draworder":"topdown", "height":100, "name":"Object Layer 1", "objects":[ { "height":52.2466039707419, "id":3, "name":"", "rotation":0, "type":"", "visible":true, "width":827.949256794968, "x":104.493207941484, "y":353.187042842215 }, { "gid":1, "height":36, "id":5, "name":"", "rotation":0, "type":"", "visible":true, "width":32, "x":291.210031347962, "y":285.502612330199 }, { "gid":1, "height":36, "id":6, "name":"", "rotation":0, "type":"", "visible":true, "width":32, "x":362.619153674833, "y":289.714922048998 }, { "gid":1, "height":36, "id":7, "name":"", "rotation":0, "type":"", "visible":true, "width":32, "x":422.010393466964, "y":291.199703043801 }, { "gid":1, "height":36, "id":8, "name":"", "rotation":0, "type":"", "visible":true, "width":32, "x":496.249443207127, "y":271.897550111359 }, { "gid":1, "height":36, "id":9, "name":"", "rotation":0, "type":"", "visible":true, "width":32, "x":555.640682999258, "y":268.927988121752 }, { "gid":1, "height":36, "id":10, "name":"", "rotation":0, "type":"", "visible":true, "width":32, "x":613.547141796585, "y":309.01707498144 }, { "gid":2, "height":134, "id":11, "name":"", "rotation":0, "type":"", "visible":true, "width":128, "x":675.420935412027, "y":300.110616184113 }, { "gid":2, "height":134, "id":12, "name":"", "rotation":0, "type":"", "visible":true, "width":128, "x":151.293244246474, "y":306.049740163326 }, { "height":34.1499628804751, "id":13, "name":"", "rotation":0, "type":"", "visible":true, "width":498.886414253898, "x":1135.8574610245, "y":357.832219747587 }], "opacity":1, "type":"objectgroup", "visible":true, "width":100, "x":0, "y":0 }], "nextobjectid":14, "orientation":"orthogonal", "renderorder":"right-down", "tileheight":32, "tilesets":[ { "columns":0, "firstgid":1, "margin":0, "name":"Objects", "spacing":0, "tilecount":2, "tileheight":134, "tiles": { "0": { "image":"..\/images\/cassettes.png" }, "1": { "image":"..\/images\/Enemy.png" } }, "tilewidth":128 }], "tilewidth":32, "version":1, "width":100 });
  16. Hello fellow phaser users I have been playing around a bit with tiled to make my 2D maps for a phaser game. But I have 2 problems that I cant seem to find the answer to : I made myself a script that a pokemon appears if I run on a specific layer. But I'm a bit stuck it keeps on finding pokemons because it keeps on saying that i'm in touch with the layer. var pokemonwild = game.physics.arcade.overlap(player, layerbackground); console.log(pokemonwild) This is what I am using right now. What should I add so it only checks once for an overlap each time I move? Also a small problem I cant get solved in tiled I made a layer named " frontgroundLayer" as purpose that it has to hide the player if it runs into that layer. For exmaple if the player runs into long grass you will see the long grass instead of the player. I have no problems with making them collide I just cant seem to find a way for the player to hide behind a tree for example. Thanks for the read hopefully anyway can help me Kind regards
  17. Hello all! I am trying to create a Tiled map for a little sidescrolling game i'm making, and I've followed the Phaser and Tiled documentation, but I for whatever reason cannot get the map imported correctly. I'm using Phaser v2.4.4, and one of the errors I'm getting is "Phaser.Tileset - image tile area is not an even multiple of tile size", and through a series of tests I found that my tilemap isn't even loading in which is probably the main reason for my issues. I have it in the preload (game.load.tilemap('Doom_Map', 'js/Doom_Map.json', null, Phaser.Tilemap.TILED_JSON); ) and in the create function (map = game.add.tilemap('Doom_Map');) but it seems to die out here. Any help or ideas would be appreciated!
  18. Hi, I have create a simple tilemap using tiled editor the map has just single layer but when I tried to collide my player with tilemap then this wired problem happened. Sometimes my player collide correctly sometime it overlapping. pic more more details understanding. here is the minimal code for full project https://github.com/shohan4556/Cowboy-Shooter/tree/master/script MyGame.playState.prototype = { create: function () { console.log(game.state.getCurrentState()); this.game.physics.startSystem(Phaser.Physics.ARCADE); this.map = this.game.add.tilemap('tilemap'); this.map.addTilesetImage('sheet','tileset'); // create the layer this.layer = this.map.createLayer(0); this.layer.resizeWorld(); this.map.setCollisionBetween(0, 133); }, update: function () { this.game.physics.arcade.collide(this.player, this.layer); }, the first image is overlapping and the second image is colliding with the tile. it happens randomly when I move my player around.
  19. Hello, I was using Arcade physics and the collisions were working perfectly fine when defined as physics.arcade.collide. In my game, I have an AI character moving in a straight line, flipping direction when colliding with walls. Walls are defined in a layer, with a custom property 'collision' set to true. (defined in Tiled). I had to switch to P2 physics as I needed more sophisticated collisions for some objects that had polygon shapes, and also had to use something that P2.Spring defines. With P2, when my AI collides with the walls it bounces back in XY direction - while the ideal behaviour is that with - this.body.velocity.x *= -1; OR this.body.velocity.y *= -1; - It should only remain on its axis. I thought I would solve it by checking collision bodies in setPostBroadphaseCallback but that does not seem to work as desired or may be I am missing something very obvious. if(body1 != null && body1.sprite != null && body1.sprite.key === 'enemy'){ // I would want to check body2 as I do body1 but for my tile body2.sprite is NULL. } I even tried comparing with each wall body gotten from the below method - this.walls = this.game.physics.p2.convertTilemap(this.map, this.layers[layer.name]); The walls collision is defined as below - for(var i=0; i<this.walls.length; i++){ this.walls.setCollisionGroup(this.collision_groups["wallCG"]); this.walls.collides(this.collision_groups["playerCG"]); this.walls.collides(this.collision_groups["enemyCG"]); } Is there a way that I would know the collision group of body2? OR compare collision groups and not body1 and body2 in setPostBroadphaseCallback? Please help. It's urgent. Thanks in advance! agogiam
  20. Hello phaser community, I've been trying for quite some time now to just make a simple map where I can walk over and have a collision when I walk against a rock. As I dont have any errors with the direct code itself ( atleast looks like it) It doesnt seem to give me errors when it tries to load the tiled files : I rewrote my code a decent amouth of times following different guides but i seem to keep on getting this error. hopefully someone can help me Kind regards Files for the whole project : index.html phaser.js WaterfallCave.json WaterfallCave.tmx
  21. Hello, I'm new with phaser and I'm building a platform game. I'm using tiled to create my map, I created an object Layer to place the player and the same enemy in specific points of the map, I did the enemies with this: var enemies = this.game.add.group(); this.map.createFromObjects('objectsLayer', 81, 'zombie', 0, true, false, this.enemies); They are showing on the map correctly but I don't know how to give them gravity, change their hitbox, animations, etc. They are just sprites floating there with no life. I want to give an enemy all the configuration and then make it affect all the enemies, also put them in a group. If there is another way please tell me. I was using this tutorial https://gamedevacademy.org/html5-phaser-tutorial-top-down-games-with-tiled/ sorry for my english.
  22. Hi, in a game I'm developing I'm trying to implement the entity component model in such a way that I can have units get their components information from the tiledMap file, I load the components from the Json like so if (object.properties.components !== "") { object.properties.components.split(",").forEach(function (componentName) { entity.addComponent(new FYP.Components[componentName](this)); }, this); } FYP.Entity.prototype.addComponent = function (component) { 'use strict'; // Add component data to the entity // NOTE: The component must have a name property (which is defined as // a prototype protoype of a component function) this.components[component.name] = component.name; return this; }; FYP.Components.PlayerInputComponent = function () { 'use strict'; this.cursors = null; return this; }; FYP.Components.PlayerInputComponent.prototype = new FYP.Components.PlayerInputComponent(); FYP.Components.PlayerInputComponent.prototype.name = 'PlayerInputComponent'; FYP.Components.PlayerInputComponent.prototype.type = 'Input'; FYP.Components.PlayerInputComponent.prototype.constructor = FYP.Components.PlayerInputComponent; FYP.Components.PlayerInputComponent.prototype.initialize = function (actor) { 'use strict'; this.cursors = actor.game.keyboard.createCursorKeys(); this.cursors.leftHand = this.keyboard.addKey(Phaser.Keyboard.X); this.cursors.rightHand = this.keyboard.addKey(Phaser.Keyboard.Z); this.cursors.pause = this.keyboard.addKey(Phaser.Keyboard.P); }; FYP.Entity = function (game, position, spriteKey) { 'use strict'; Phaser.Sprite.call(this, game, position.x, position.y, spriteKey); this.commands = []; this.components = []; // Set the pivot point for this sprite to the center this.anchor.setTo(0.5, 0.5); return this; }; FYP.Entity.prototype = Object.create(Phaser.Sprite.prototype); FYP.Entity.prototype.constructor = FYP.Entity; FYP.Entity.prototype.update = function () { 'use strict'; if (this.components) { this.components.forEach(function (component) { component.update(); console.log(component); }, this); } this does not work however, and even though Entity.components seems to contain all the appropriate components the array always seems to have a length of 0 so I can't traverse it to execute the update functions
  23. I'm defining the collision bounds of my game world using rectangle objects in Tiled. Is there an easy way to convert rectangle objects made in Tiled on an objects layer into Arcade physics bodies?
  24. tl;dr: Do you know any automated tool with which it is possible to decrypt / reverse engineer / find tiles in a tileset based on an existing game's level images? So, given: 1) a tileset, with relatively lot, 16x16 tiles, and 2) enormous level images (with the same resolution) built with these 16x16 tile blocks once. Is it possible to automate the matching of single 16x16 tiny tiles to get a full level map from the big image somehow? As far as i know state of image recognition this is a fairly straightforward task. Are there any solutions already?
  25. <!DOCTYPE HTML> <html> <head> <title>Phaser Tiled Test</title> </head> <body> <div id="renderer_container"> <!-- /renderer_container --> </div> <script src="phaser.min.js"></script> <script src="main.js"></script> </body> </html> var map; var layer; var keyArrow; var game = new Phaser.Game(800, 600, Phaser.AUTO, 'renderer_container', { preload : preload, create : create, update : update, render : render }); function preload() { game.load.tilemap('map', 'testMap.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('tiles', 'map.png'); } function create() { map = game.add.tilemap('map'); // Now add in the tileset map.addTilesetImage('tiles'); // Create our layer layer = map.createLayer(0); // Resize the world layer.resizeWorld(); // Allow keyArrow to scroll around the map keyArrow = game.input.keyboard.createCursorKeys(); var help = game.add.text(16, 16, 'Arrows to scroll', { font : '14px Arial', fill : '#ffffff' }); help.fixedToCamera = true; } function update() { if (keyArrow.left.isDown) { game.camera.x -= 4; } else if (keyArrow.right.isDown) { game.camera.x += 4; } if (keyArrow.up.isDown) { game.camera.y -= 4; } else if (keyArrow.down.isDown) { game.camera.y += 4; } } function render() {} Hi Just learning phaser. I am trying to load a simple tiled map. But i am getting an undefined exception for the "map" object.