Dlost1

Members
  • Content count

    16
  • Joined

  • Last visited

  1. Hooohoo! It works! Thanks samid737 and all others who helped me out. Now I also understand why spritesheets often have images facing only one direction. With objects.scale.x*=-1; it gets swapped with ease. Not sure if I am allowed to say this here but I got the sprites from opengameart, Samid (since you liked ehm). @Symof Thanks I went for the bounce but you gave me some more insight in the js side. Happy it works but still feeling slightly frustrated that I didn't find a solution myself;) A well on to shooting fireballs and such.
  2. Thank you for the effort! I am gonna try your suggestions. You are right, I figured there is lots more Phaser can do. But, I did follow courses in Java. I am pretty novice to JS and Phaser seemed a nice platform to learn more about JS frameworks and a bit of JS while making a fun game;) Iam still learnig to use the framework/libraries the right way:) Thanks for the help! I ll let you know if it works in a bit. First I need a 30 minutes break lol
  3. Hi:) I tried that before, but problem is that I did like this : x______S_____x the x are both small collision tile blocks. The ___ is a tilefloor The S is a skeleton on patrol between the two x. When hitting the x the direction should change . Your idea only sends him 1 way...sadly:S
  4. Thanks! I am still learning JS...I forgot about the reserved keyword do:) Thanks. Furher I am gonna try checking bot x and y. I ll get back to this topic and let you know the result!
  5. Hello, I am creating a small platformer. I want my npc enemy-sprites to move into the other direction when they collide with a block of layer4. However the "if' statement does not work. Which is weird cause speed/velocity often checks as 0 ( see lowest code snippet from runntime). So: How do I make the If statement in the do-function fire???? (uploaded it to github : https://github.com/dijoluc/DungeonDouble ) FYI: the update function is part of the Game1.js and the do function is part of the npc.js file. In update function game.physics.arcade.collide(badguys, this.layer3); //calling the do function game.physics.arcade.collide(badguys, this.layer4, npc.do(this.badguys), null, this ); do: function(objects){ //badguys = the group of ennemies badguys.forEach(function(element) { //debugging console.log(element.body.velocity.x); //set speed to 50 element.body.velocity.x = 50; if(element.body.velocity === 0 || element.body.velocity === -0){ //reverse speed to move in opposite direction element.body.onCollide = element.body.velocity.x *= -1; } My debugging/development console screen: From my developerstool while running Phaser CE v2.7.3 | Pixi.js | WebGL | WebAudio http://phaser.io ♥♥♥ 3 VM1498:15 0 // 3 times an element/object was checked to have 0 speed 101 VM1498:15 50 // 101 times an element/object was checked to have 50 speed VM1498:15 0 // 1 time an element/object was checked to have 0 speed 5 VM1498:15 50 // 5 times an element/object was checked to have 50 speed VM1498:15 0 // 1 time an element/object was checked to have 0 speed 5 VM1498:15 50 // 5times an element/object was checked to have 50 speed VM1498:15 0 5 VM1498:15 50 // 5times an element was checked to have 50 speed VM1498:15 0 // 1 time an element/object was checked to have 0 speed 5 VM1498:15 50 // 5times an element was checked to have 50 speed So it does check elements for 0 velocity...so why does my If not fire??
  6. Maybe still useful, I thought this was a pretty good tutorial (explanation included on the gitpage): https://github.com/MattMcFarland/phaser-menu-system
  7. 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:
  8. 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?
  9. 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:
  10. 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'); }
  11. 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.
  12. 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!
  13. 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:)
  14. Also: please let me know if my question is not clear enough;))
  15. 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');