Dlost1

Members
  • Content count

    10
  • Joined

  • Last visited

  1. Ok, I finally got it:) For other people struggling with this: I refered to the wrong labels here is what I did to solve it. It is highly likely that there is a better way than my rugged sollution, though. And ofcourse I d be happy to see comments improving my solution;) I did as follows to fix this: The whole structure of my Json file to complete my solution:
  2. Still hoping to get some help (please?;))... apparantly the coin example is ancient. (https://phaser.io/examples/v2/tilemaps/create-from-objects) So I tried to auto add a gid myself (the game will have lots of objects): http://stackoverflow.com/questions/38544978/gid-in-tile-map However I get: Uncaught TypeError: Cannot read property 'objects' of undefined <-----------------Huh? at Game.create (<anonymous>:177:10) at Phaser.StateManager.loadComplete (phaser.js:28530) at Phaser.StateManager.preUpdate (phaser.js:28307) at Phaser.Game.updateLogic (phaser.js:34908) at Phaser.Game.update (phaser.js:34801) at Phaser.RequestAnimationFrame.updateRAF (phaser.js:62538) at _onLoop (phaser.js:62521) So I CAN acces "ObjectLayer" but "objects" gives undefined? What gives? Again Json: Anyone got any idea why I get undefined?
  3. Hi!! I would like to know: How do I refer to a Tiled/Json object id/name from phaser? I created an object in Tiled and when the user enters the area of this object (called tavern) a new game world/map should be opened (the player will enter the Tavern-map). How can I refer to an object in the object layer in my Json/Tiled map? something like: var one = map.object.id(x) if(playerX,playerY == oneX, oneY){game.state.start('GameMap2');} Any idea's? An example to do this perhaps? Thanks in advance:) (I have also tried: createFromObjects(name, gid, key, frame, exists, autoCull, group, CustomClass, adjustY) Also attempted to copy the following example, but did does not work (it uses a gid...I do not have a gid in my Json I tried to us the "id" in its stead. This resulted in "undefinded" errors). https://phaser.io/examples/v2/tilemaps/create-from-objects But in my Json there is no "gid" Json code:
  4. Hi:) I am trying to use one key (E) for 2 actions --> animation slashLeft and animation slashRight depending on the char facing left or right (to where the enemy will be) I came up with the stuff below...is there a better way? Please tell me there is:/ (so you can walk and hit at the same time, in example?) //More cursor-key-code above this else if(this.keyE.isDown){ if(cursors.left.upDuration(200)) { player.animations.play('slashLeft'); }else if(cursors.right.upDuration(200)) { player.animations.play('slashRight'); }
  5. Thanks:) So I am not that far off;) Good to know! Got a complex map so its gonna be a lot of work, though:/ I geuse less layers will mean better performance. So I ll try to limit that.
  6. Hello! Just looking for some advice: I am building a 2D-adventure game. I want my char collide with a building when walking up from below or from the side (partly) I want my char to walk behind to higher part of a building (the rooftop). So I was thinking to approach this by splitting the building into 2 objects: the lower part of the building and the roof. Than I might place the lower part in a object collision layer and the upper part in a "behind" layer. Now, I am wondering; is this the way to do it? Or is this a noobish approach? --> If so, how should I do it? --> I am using Tiled//Phaser btw;) Would love to hear your idea's!
  7. Well it does solve the speed problem indeed. I think I ll go with that unless anyone has a suggestion for a more beautiful solution form my problem?:) Thanks Samme:)
  8. Also: please let me know if my question is not clear enough;))
  9. Hello, I am building a small Phaser game. For fun;) I got one problem: I focus my camera on my character, but when I near the edge of the map the characters speed "seems" to increase greatly (and decrease as soon as the camera starts moving of the edge again). I think this has to do with the camera abruptly stopping when on the edge of the map (so the cam stops but char moves on) Is there a way to make the camere go "over the edge", like, half or so? Cause this looks a bit crappy;) Underneath I posteed the code (I took out the parts which have nothing to do with this issue:) Anyone got an idea or a sollution for me? (Btw: I am using Tiled to create a Json map which I imported into my program.) create: function () { game.world.setBounds(0, 0, 2560, 2560); game.physics.startSystem(Phaser.Physics.ARCADE); this.map = game.add.tilemap("GameWorld1616", 16, 16, 160, 160); this.map.addTilesetImage("Ground1","Ground1"); this.map.addTilesetImage("Market2", "Market2"); this.map.addTilesetImage("Tree1", "Tree1"); this.layer1 = this.map.createLayer("GroundLayer"); this.layer2 = this.map.createLayer("Roads"); this.layer3 = this.map.createLayer("TreesFront"); this.layer4 = this.map.createLayer("TreesBack"); this.layer5 = this.map.createLayer("Collision"); player = game.add.sprite(game.world.centerX, game.world.centerY, avatar); game.camera.follow(player); game.physics.arcade.enable(player); player.body.collideWorldBounds = true; cursors = game.input.keyboard.createCursorKeys(); this.menuFactory('Return', function () { game.state.start("CharSelect"); }); }, update: function() { game.physics.arcade.collide(player); // Reset the players velocity (movement) player.body.velocity.x = 0; player.body.velocity.y = 0; if (cursors.left.isDown) { // Move to the left player.body.velocity.x = -500; player.animations.play('left'); } else if (cursors.right.isDown) { // Move to the right player.body.velocity.x = 500; player.animations.play('right');