damiansito

Members
  • Content Count

    5
  • Joined

  • Last visited

  1. But doesn't that assume that there is a sprite 'enemy' to use? In my case, it is purely polylines. No sprite associated with it.
  2. 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!
  3. I even made the map in tiled from scratch and completely changed everything. This time I made two layers. One with all the tiles and another for a collision layer. And still nothing is showing up. It makes no sense!!
  4. Yes I have tried that. I am still getting the same errors along with the error: 'Uncaught TypeError: Cannot read property resizeWorld of undefined.' If I comment out the resize_world line, then I still get the same errors as before but the screen is black.
  5. Hello guys! This is my first time here. I have looked through a lot of posts already trying to find the answer, but for some reason nothing is working for me!!! I am using tiled to get the map data and I have included it just fine since I was following the tutorials. So the first layer shows, but as soon as I create another layer that has my objects that will collide with the user, they don't appear. I have no idea what I am doing wrong. I am using the responsive template that came with phaser, which is why everything is in different files and stuff. This is my game.js BasicGame.Game = function (game) { // When a State is added to Phaser it automatically has the following properties set on it, even if they already exist: this.game; // a reference to the currently running game this.add; // used to add sprites, text, groups, etc this.camera; // a reference to the game camera this.cache; // the game cache this.input; // the global input manager (you can access this.input.keyboard, this.input.mouse, as well from it) this.load; // for preloading assets this.math; // lots of useful common math operations this.sound; // the sound manager - add a sound, play one, set-up markers, etc this.stage; // the game stage this.time; // the clock this.tweens; // the tween manager this.state; // the state manager this.world; // the game world this.particles; // the particle manager this.physics; // the physics manager this.rnd; // the repeatable random number generator this.player; this.cursors; this.map; this.ground_layer; this.tree_layer; this.building_layer;};BasicGame.Game.prototype = { create: function () { //// We're going to be using physics, so enable the Arcade Physics system this.game.physics.startSystem(Phaser.Physics.ARCADE); //this.map = this.add.tilemap('littleroot'); this.map = this.game.add.tilemap('littleroot'); this.map.addTilesetImage('tiles', 'gameTiles'); this.ground_layer = this.map.createLayer('ground'); this.tree_layer = this.map.createLayer('trees'); this.building_layer = this.map.createLayer('buildings'); //this.map.setCollisionBetween(1, 9962, true, 'trees'); //this.map.setCollisionBetween(1, 9962, true, 'buildings'); this.ground_layer.resizeWorld(); //this.tree_layer.resizeWorld(); //// The player and its settings this.player = this.game.add.sprite(32, this.game.world.height - 150, 'dude'); // //// We need to enable physics on the player this.game.physics.arcade.enable(this.player); //this.player.body.collideWorldBounds = true; //// Our two animations, walking left and right. this.player.animations.add('left', [0, 1, 2, 3], 10, true); this.player.animations.add('right', [5, 6, 7, 8], 10, true); //// Our controls. this.camera.follow(this.player); this.cursors = this.game.input.keyboard.createCursorKeys(); }, update: function () { this.game.physics.arcade.collide(this.player, this.tree_layer); this.game.physics.arcade.collide(this.player, this.building_layer); // Reset the players velocity (movement) this.player.body.velocity.x = 0; this.player.body.velocity.y = 0; if (this.cursors.left.isDown) { // Move to the left this.player.body.velocity.x = -150; this.player.animations.play('left'); } else if (this.cursors.right.isDown) { // Move to the right this.player.body.velocity.x = 150; this.player.animations.play('right'); } else if (this.cursors.up.isDown) { // Move up this.player.body.velocity.y = -150; //this.player.animations.play('up'); } else if (this.cursors.down.isDown) { // Move down this.player.body.velocity.y = 150; //this.player.animations.play('down'); } else { // Stand still this.player.animations.stop(); this.player.frame = 4; } }, quitGame: function (pointer) { // Here you should destroy anything you no longer need. // Stop music, delete sprites, purge caches, free resources, all that good stuff. // Then let's go back to the main menu. this.state.start('MainMenu'); },};This is my preloader.js BasicGame.Preloader = function (game) { this.background = null; this.preloadBar = null; this.ready = false;};BasicGame.Preloader.prototype = { preload: function () { // These are the assets we loaded in Boot.js // Load tile map data for the tile set this.load.tilemap('littleroot', 'assets/tiles/pk_emerald_map.json', null, Phaser.Tilemap.TILED_JSON); // Load the tileset this.load.image('gameTiles', 'assets/tiles/pk_emerald_map.png'); this.load.spritesheet('dude', 'assets/sprites/dude.png', 32, 48); }, create: function () { this.state.start('MainMenu'); }};I also tried uploading my json file, but I got this error: 'You aren't permitted to upload this kind of file'. So hopefully it's a code error and nothing to do with the json! I am also getting these warnings: 1) Phaser.Tileset - image tile area is not an even multiple of tile size phaser.min.js:24 2) Tilemap.createLayer: Invalid layer ID given: null phaser.min.js:24 Maybe these have something to do with it? I know I am missing something fundamental here because I looked through many tutorials and all of their layers work. Thanks for the help guys!