ChetD90

Members
  • Content Count

    8
  • Joined

  • Last visited

  1. ChetD90

    I can't get my scenes to load

    My scenes with the maps I created are not loading in the browser. To get an overview of what is going on, I am creating a game RPG like game that that has a top down view of the character. The game I am making requires the character go into a store and buy some items. I think I may have found a solution for the problem of switching between maps using multiple scenes. However, the problem now is that the map isn't loading and when inspect the game in chrome an error message that reads "Uncaught Reference Error: SceneA not define at index.js: 19". I thought that I set up the code correctly. But see what I did wrong, so I will include the js file since it is over 360+ lines of code. index.js
  2. ChetD90

    How do I get a character to enter a building?

    Update: I got the character to load on the map with the function I already have but problem is that I can’t move my character. Here is the function I have so far: // When the player walks into the store. player.onCollide = new Phaser.signal(); Store.onCollide.add(enterstore,this); function enterstore(player){ const map2 = this.make.tilemap({ key: "map2" }); const tileset2 = map.addTilesetImage("store", "tiles2"); const storeLayer = map.createStaticLayer("Tile Layer 1", tileset, 0, 0); storeLayer.setCollisionByProperty({ collides: true }); this.physics.add.collider(player, storeLayer); storeLayer.setDepth(10); const SpawnPoint = map.findObject("Objects", obj => obj.name === "Spawn Point"); const Store = map.findObject("Objects", obj => obj.name === "store"); player = this.physics.add .sprite(SpawnPoint.x, SpawnPoint.y, "atlas", "misa-front") .setSize(30, 40) .setOffset(282, 202); }; Run code snippet
  3. ChetD90

    How do I get a character to enter a building?

    Thank you for the responses, right I am trying to get my character to "teleport" to a different map using a object that appears in the map. The character is supposed to walk into that object and go into the building and appear in a store that is on a different map. In order to facilitate this do I need to use the setCollisionByProperty or collider function in order to detect to player walking into it. Also, I need to make a const variable of the "store" object. Therefore, I guess I am trying to build the code that will make this happen. function preload() { this.load.image("tiles", "../assets/tilesets/RunItUpCity.png"); this.load.tilemapTiledJSON("map", "../assets/tilemaps/GetawayCity.json"); this.load.image("tiles2", "../assets/tilesets/modern-day-shop-add-on-right.png"); this.load.tilemapTiledJSON("map2", "../assets/tilemaps/store.json"); // An atlas is a way to pack multiple images together into one texture. I'm using it to load all // the player animations (walking left, walking right, etc.) in one image. For more info see: // https://labs.phaser.io/view.html?src=src/animation/texture%20atlas%20animation.js // If you don't use an atlas, you can do the same thing with a spritesheet, see: // https://labs.phaser.io/view.html?src=src/animation/single%20sprite%20sheet.js this.load.atlas("atlas", "../assets/atlas/atlas.png", "../assets/atlas/atlas.json"); } function create() { const map = this.make.tilemap({ key: "map" }); // Parameters are the name you gave the tileset in Tiled and then the key of the tileset image in // Phaser's cache (i.e. the name you used in preload) const tileset = map.addTilesetImage("RunitUpCity", "tiles"); // Parameters: layer name (or index) from Tiled, tileset, x, y const belowLayer = map.createStaticLayer("Bottom Layer", tileset, 0, 0); const worldLayer = map.createStaticLayer("Top Layer", tileset, 0, 0); const aboveLayer = map.createStaticLayer("Collision Layer", tileset, 0, 0); worldLayer.setCollisionByProperty({ collides: true }); // By default, everything gets depth sorted on the screen in the order we created things. Here, we // want the "Above Player" layer to sit on top of the player, so we explicitly give it a depth. // Higher depths will sit on top of lower depth objects. worldLayer.setDepth(10); // Object layers in Tiled let you embed extra info into a map - like a spawn point or custom // collision shapes. In the tmx file, there's an object layer with a point named "Spawn Point" const spawnPoint = map.findObject("Objects", obj => obj.name === "Spawn Point"); const Store = map.findObject("Objects", obj => obj.name === "store");
  4. I am making a top down RPG styled game using Tiled and Phaser 3. I have already made a map in Tiled for the city and store. Also, I have already set the objects for the location of the store where the player is suppose to go in order to enter the store and the location where the player is supposed to appear. The thing I am having trouble figuring out the code I am suppose to use in order to facilitate this action, as well as going back to city map. One more thing, If there are any other ideas on how to go about this I am all ears.
  5. Ok, solved the problem of getting the map to load by exporting the map as a csv in Tiled and saving a json of the map. However, I now have the problem of not getting anything to move on the map. Do you think that I make that into a new topic.
  6. Whoa! what are you talking about? I don't even have enemies.children.iterate in my code. Also, I switched the layer compression from Base64(compressed) to Base64(uncompressed). Do you think I should use CSV or XML format?
  7. I used the line of code in my JavaScript file and I got an error of 'Uncaught TypeError: Cannot read property 'cache' of undefined at index.js:7'. Also, how exactly do I turn off the layer compression? Do you change the Tile Layer format?
  8. I have made a map in Tiled and I have a already generated a JSON. Whenever I try to load the map in Chrome and it load only a black screen. When I went to inspect the website there are warning like: No data found in the Json tilemap from Tiled matching the tileset name "RunItUpCity" Cannot create tilemap layer, invalid layer ID given: Bottom Layer TilemapParser.ParseTiledJSON - Layer compression is unsupported, skipping layer 'Bottom Layer' Also, I got an Error that read: Uncaught Type Error: cannot read property 'setCollisionProperty' of null Does anyone think that there is a problem with the map or the code? Here is the JavaScript code if anyone needs it. const config = { type: Phaser.AUTO, width: 800, height: 600, parent: "game-container", pixelArt: true, physics: { default: "arcade", arcade: { gravity: { y: 0 } } }, scene: { preload: preload, create: create, update: update } }; const game = new Phaser.Game(config); let cursors; let player; let showDebug = false; function preload() { this.load.image("tiles", "../assets/tilesets/RunItUpCity.png"); this.load.tilemapTiledJSON("map", "../assets/tilemaps/GetawayCity.json"); // An atlas is a way to pack multiple images together into one texture. I'm using it to load all // the player animations (walking left, walking right, etc.) in one image. For more info see: // https://labs.phaser.io/view.html?src=src/animation/texture%20atlas%20animation.js // If you don't use an atlas, you can do the same thing with a spritesheet, see: // https://labs.phaser.io/view.html?src=src/animation/single%20sprite%20sheet.js this.load.atlas("atlas", "../assets/atlas/atlas.png", "../assets/atlas/atlas.json"); } function create() { const map = this.make.tilemap({ key: "map" }); // Parameters are the name you gave the tileset in Tiled and then the key of the tileset image in // Phaser's cache (i.e. the name you used in preload) const tileset = map.addTilesetImage("RunitUpCity", "tiles"); // Parameters: layer name (or index) from Tiled, tileset, x, y const belowLayer = map.createStaticLayer("Bottom Layer", tileset, 0, 0); const worldLayer = map.createStaticLayer("Top Layer", tileset, 0, 0); const aboveLayer = map.createStaticLayer("Collision Layer", tileset, 0, 0); aboveLayer.setCollisionByProperty({ collides: true }); // By default, everything gets depth sorted on the screen in the order we created things. Here, we // want the "Above Player" layer to sit on top of the player, so we explicitly give it a depth. // Higher depths will sit on top of lower depth objects. worldLayer.setDepth(10); // Object layers in Tiled let you embed extra info into a map - like a spawn point or custom // collision shapes. In the tmx file, there's an object layer with a point named "Spawn Point" const spawnPoint = map.findObject("Objects", obj => obj.name === "Spawn Point"); Also, I will attach the JSON code to the post because it is 17000+ of code. GetawayCity.json