• Content Count

  • Joined

  • Last visited

About Dlost1

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thats it! Thank you! But..how did you know to use 'scale.x' ? This is something you just " have to know' ...or is there any logic to it I am missing out on?
  2. Hello, I created weapon animated from a spritesheet however the images on the sheet where a bit oversized. I know I can make the spritesheet smaller but it kindoff defeats my purpose of learning more in programming;) So when I scaled the weapon itself (fireball) to be half its sprites size its starting position also changed. Therefore I figured I' d anchor the weapon in the right position. But for some reason it keeps stating " anchor = undefined". So, anyone sees whats going wrong here? //This line is the one bugging out. I tried setting the anchor on each bullet and on the weapon itself. The console states 'anchor is undefined" this.weapon.anchor.setTo(0.5, 0.5); var weapon; create: function () { game.world.setBounds(0, 0, 1920, 560); game.physics.startSystem(Phaser.Physics.ARCADE); game.physics.arcade.gravity.y = 1000; this.weapon = game.add.weapon(1, "fireball"); // here I scale the weapon the fireball this.weapon.bullets.scale.setTo(0.5); this.weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; this.weapon.bulletSpeed = 300; this.weapon.fireRate = 500; //will use more sprites in the near future this.weapon.addBulletAnimation('fire',[23], 10, true ); this.weapon.trackSprite(player, 0, 0 , false); this.weapon.allowGravity = false; this.weapon.bulletGravity.y = -1000; //here I attempt to set the anchor so the weapon will be pushed to the right startposition this.weapon.anchor.setTo(0.5, 0.5); //this.weapon = action.attack.weapon; console.log(this.weapon); //u create controls cursors = game.input.keyboard.createCursorKeys(); //register hotkey this.fire = game.input.keyboard.addKey(Phaser.Keyboard.W); // Stop the following keys from propagating up to the browser game.input.keyboard.addKeyCapture([Phaser.Keyboard.E]); },
  3. Dlost1

    If velocity than

    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.
  4. Dlost1

    If velocity than

    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
  5. Dlost1

    If velocity than

    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
  6. Dlost1

    If velocity than

    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!
  7. Dlost1

    If velocity than

    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??
  8. Maybe still useful, I thought this was a pretty good tutorial (explanation included on the gitpage): https://github.com/MattMcFarland/phaser-menu-system
  9. 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:
  10. 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?
  11. 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:
  12. 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'); }
  13. 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.
  14. 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!
  15. 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:)