Search the Community

Showing results for tags 'follow'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 15 results

  1. I do not find the error in this code anyone help me please. I'm doing a topdown game but I can not get the camera to follow the sprite player.... Sorry if I'm doing something wrong! this.Camera.follow (player, Phaser.Camera.FOLLOW_TOPDOWN); this does not work ! do not open anything; When I remove it everything works normal var config = { type: Phaser.CANVAS, width: 1920, height: 1080, physics: { default: 'arcade', acarde:{ //gravity:{ } debug: false } }, scene: { preload: preload, create: create, update: update } }; var game = new Phaser.Game(config); function preload () { this.load.image('ground', 'images/ground-smart.png'); //pedras this.load.image('stone1', 'images/stone-1.png'); this.load.image('stone5', 'images/stone-5.png'); //flores this.load.image('flor1', 'images/flor1.png'); this.load.image('flor2', 'images/flor2.png'); this.load.image('flor3', 'images/flor3.png'); //player this.load.spritesheet('player1', 'images/p-anim.png', { frameWidth: 128, frameHeight: 90 }); } function create () { this.add.image(960, 540, 'ground'); this.add.image(64, 430, 'stone1'); this.add.image(650, 80, 'stone5'); flores = this.physics.add.staticGroup(); flores.create(400, 350, 'flor1'); flores.create(220, 90, 'flor3'); player = this.physics.add.sprite(400, 300, 'player1'); this.Camera.follow(player, Phaser.Camera.FOLLOW_TOPDOWN); this.anims.create({ key: 'left', frames: this.anims.generateFrameNumbers('player1', { start: 1, end: 7 }), frameRate: 6, repeat: -1 }); this.anims.create({ key: 'turn', frames: [ { key: 'player1', frame: 0 } ], frameRate: 20 }); this.anims.create({ key: 'right', frames: this.anims.generateFrameNumbers('player1', { start: 1, end: 7 }), frameRate: 10, repeat: -1 }); cursors = this.input.keyboard.createCursorKeys(); this.physics.add.collider (player, flores); } function update () { if (cursors.up.isDown) { player.setVelocityY(-160);'left', true); } else if (cursors.down.isDown) { player.setVelocityY(160);'right', true); } else { player.setVelocityX(0);'turn'); } if (cursors.up.isDown && player.body.touching.down) { player.setVelocityY(-330); } }
  2. Hey dudes So I'm continuing along with my 3d project and I've been building a prototype scene in babylon in order to test the final experience and make a few decisions. Part of my test scene involves a helicopter going around in a circle, so in blender i created a bezierCircle, parented the helicopter to it and set the parenting mode to follow path. In blender this works great when running the animation. The big problem is of course (I soon discovered) that the babylon exporter does not support beziercircles and therefore ignores the path and the helicopter model (since it is now a child object of the beziercircle). So my question is; what is the expected way to set up things like follow path animations in Blender such that the babylon exporter will support it and babylon can play the animations automatically? Cheers!
  3. Camera problem - following player

    Hello I'm having an interesting problem with my camera, this is how my game looks without the camera following the player this is how it looks following the player... (the only good thing is that it actually follows the player) but I would like to know how to set up the bounds of the camera and to make sure it doesn't ... well do this. here's my code : scenes.scene3 = function(){}; //Player speed var link, vel = 150; //Map/Level var map; //Tiled Layers var floor, water,walls; //Object Tiled Layers var rocks var bushes1, bushes2, bushes3, bushes4; scenes.scene3.prototype = { preload: function (){ game.load.image('tiles', 'Assets/Sprites/Levels/zelda_01.png'); music ='openWorld'); music.addMarker('openWorld', 0, 16, true); game.renderer.resize( 1216/2, 800/2); }, create: function (){ //Game itself,0, 1216, 800); game.physics.startSystem(Phaser.Physics.ARCADE); map = game.add.tilemap('level_01'); map.addTilesetImage('tiles'); floor = map.createLayer('ground'); walls = map.createLayer('walls'); water = map.createLayer('water'); map.setCollisionBetween(0, 100, true, 'walls'); map.setCollisionBetween(0, 100, true, 'water'); //Objects layer related rocks = game.add.physicsGroup(); map.createFromObjects('rocks','ROCK','tiles', 48, true, false, rocks); rocks.forEach(function(rocks){rocks.body.immovable = true;}); bushes = game.add.physicsGroup(); map.createFromObjects('bushes', 'BUSHTOP', 'tiles', 37, true, false , bushes); map.createFromObjects('bushes', 'BUSHBOT', 'tiles', 35, true, false , bushes); map.createFromObjects('bushes', 'BUSHLEFT', 'tiles', 36, true, false , bushes); map.createFromObjects('bushes', 'BUSHRIGHT', 'tiles', 34, true, false , bushes); bushes.forEach(function(bushes){bushes.body.immovable = true;}); //'openWorld', 0,1,true); // Player link = game.add.sprite((centerX-500), 100, 'LinkMovement'); link.scale.setTo(0.25, 0.25); link.animations.add('walkHorizontalRight', [6,7,8]); link.animations.add('walkHorizontalLeft', [9,10,11]); link.animations.add('walkVerticalDown', [0,1,2]); link.animations.add('walkVerticalUp', [3,4,5]); game.physics.enable(link); link.body.collideWorldBounds=true; //Life bar life = game.add.sprite((centerX-600), (centerY-675), 'lifeBar'); life.scale.setTo(0.15, 0.15); life.animations.add('fullHP', [0]); life.animations.add('twoHP', [1]); life.animations.add('oneHP', [2]); life.animations.add('Dead', [3]); cursors = game.input.keyboard.createCursorKeys(); var b1 = game.add.button(900,300, 'buttonFire', function() {fire();}); b1.scale.setTo(0.25,0.25); = (608,400);; }, update: function (){ game.physics.arcade.collide(link, walls); game.physics.arcade.collide(link, water); game.physics.arcade.collide(link, rocks); game.physics.arcade.collide(link, bushes); if(cursors.up.isDown){ link.body.velocity.y = -vel;'walkVerticalUp', 9, true); } else if(cursors.down.isDown){ link.body.velocity.y = vel;'walkVerticalDown', 9, true); } else{ link.body.velocity.y = 0; link.animations.stop('walkVerticalUp'); link.animations.stop('walkVerticalDown'); } if(cursors.left.isDown){ link.body.velocity.x = -vel;'walkHorizontalLeft', 9, true); } else if(cursors.right.isDown){ link.body.velocity.x = vel;'walkHorizontalRight', 9, true); } else{ link.body.velocity.x = 0; link.animations.stop('walkHorizontalRight'); link.animations.stop('walkHorizontalLeft'); } }, fire: function(){ console.log('firing') var bullet = bullets.getFirstDead(); bullet.reset(link.x, link.y); }, drawHealthBar: function(){ if (hitPoints === 3) {'fullHP'); } else if (hitPoints === 2) {'twoHP'); } else if (hitPoints === 1) {'oneHP'); } else if (hitPoints === 0) {'Dead'); } } };
  4. Hi guys! I'm doing a 2D game with tiled map and I've run into a problem. When the group of objects (map layer and unit sprites) scaled, and camera is focused on sprite (by following with lerp), camera.view, or autoCull (or something else) gets some offset lag But all works fine with image map. You can uncomment the /* image map */ section in 'create' tab to check it out. Dont forget to comment the /* tile map */ section Just look: Buttons: LEFT ARROW - center camera on unit1 and scale group to 1.2 (if not zoomed); RIGHT ARROW - center camera on unit2 and scale group to 1.2 (if not zoomed); UP ARROW - unzoom (set group scale to 1); Spent last two days to fix this out, but have no more ideas.
  5. Hi Everybody ! I'm working on a game with camera follow, and many plans on background. Is there a solution to make them moved at differents speeds ? To create parallax effect :). Thank you !! And sorry for my english ^^..
  6. Light Trail and Follow

    Hello everyone! First of all, thanks for the excellent forum! It's amazing. My question is, how to make and which the best way to make a "Light trail effect". I've make this image from photoshop to illustrate: The red dot is the point that the line shall follow. When the line becomes long, needs to fade out. I thought 2 possibilities to do it : Particles or slice and manipule a "shape" (texture), dividing in 3 parts, like : My doubt is, what is better? Or have other way to do... And, the Particles or Particles Storm from Phaser can do this? Sorry for my bad english Thanks for patience!
  7. I'm having an issue where my sprite position is not staying on top of my sprite. Please see this example i created to show the problem: - (The yellow dot is sprite position. red dot is worldTransform) When the sprite is moved to the right and lower side of the map, the sprite position (yellow dot) moves away from the sprite. It seems to have something to do with the camera bounds. I've noticed if I full screen the game to be bigger than the size of the map, this problem does not happen. only when the camera is following the player AND the map goes off screen. Also I noticed that if i remove layer.resizeWorld() the problem disappears. This is interfering with my development because I need the sprites position to be accurate. Can someone tell me why this is happening?
  8. Hi, I made a new camera follow mode, because none of existing type is what i want. I dont know if it is a great feature to Phaser lib, but to me is what i want. The only problem in my update calc, is a flick when my sprite is moving. This is my code on game update (the camera default follow code is disabled): = Math.round(this.player.sprite.x - ( / 2)); = Math.round(this.player.sprite.y - ( / 2)); = new Phaser.Rectangle(this.player.sprite.x + ( / 2), this.player.sprite.y + ( / 2), , ); Can anyone have any tips?
  9. Sprite follow doesn't work correctly

    I have started a platform game very simple, just to teaching myself, following examples and tutorials. Already searched too much the annoying problem of camera follows, because my camera doesn't follow the player correctly. The problem is the sprite player move left to right and the camera start moving but not in the same speed, so the camera doesn't center and the sprite moving far from center to right, also the cameras still moving, but can't follow the sprite speed. function GameState() {;}GameState.prototype = Object.create(Phaser.State.prototype);GameState.prototype.constructor = GameState;GameState.prototype.preload = function() { 'use strict';'map', 'static/map1.json', null, Phaser.Tilemap.TILED_JSON);'tiles', 'static/tiles.png');'hero', 'static/hero.png', 34, 38, 14);};GameState.prototype.create = function () { 'use strict'; console.log('create'); // start physics system;, 0, 6400, 640); = 1000; this.player = new Player(this, 40, 4);;; var map ='map'); map.addTilesetImage('tiles1', 'tiles'); this.layer1 = map.createLayer('layer1'); this.layer1.debug = true; this.layer1.resizeWorld(); this.layer2 = map.createLayer('layer2'); this.layer2.resizeWorld(); map.setCollision(130, true, "layer1", true);};GameState.prototype.update = function() { 'use strict';};GameState.prototype.render = function() { 'use strict';};function Player(game_state, x, y) {,, x, y, 'hero'); this.game_state = game_state; this.states = { WALKING : 'WALKING', IDLE : 'IDLE' }; this.facing = 'left'; = 0; this.isAlive = false; = 'Player'; this.currState = this.states.IDLE; console.log('Add player'); this.animations.add('idle', [1], 0); this.animations.add('walk', [0, 1], 6, true);'idle');, Phaser.Physics.ARCADE); this.body.collideWorldBounds = true; this.anchor.setTo(1); this.cursors =;}Player.prototype = Object.create(Phaser.Sprite.prototype);Player.prototype.constructor = Player;Player.prototype.changeState = function(newState) { if (newState === this.currState) { return; } this.currState = newState; console.log('Change state', newState); switch(newState) { case 'IDLE':'idle'); break; case 'WALKING':'walk'); break; }};Player.prototype.update = function() { //, this.layer1); if (this.cursors.left.isDown) { this.scale.x = 1; this.body.velocity.x = -200; } if (this.cursors.right.isDown) { this.scale.x = -1; this.body.velocity.x = 200; } if (this.cursors.right.isDown || this.cursors.left.isDown) { this.changeState('WALKING'); } else { this.body.velocity.x = 0; this.changeState('IDLE'); }};
  10. Follow Camera Issue

    Hello everyone. I'm new around here and i just started playing with Babylon js. I started working on a small project and i encountered some issues with the Follow Camera (which is amazing btw ). So, here's my problem: I have a character in the scene, i set the follow camera, i modified it a bit so it folows the caracter from behind. Now the issue is that when i set the camera target, everything i do is relative to the caracters feet (0,0,0) - rotating the camera around the object for example. How can i modify the pivot point to be the caracter's head or some point of the target object? Thanks in advance and excuse me for my poor english.
  11. Hey, I'm working on a vertical platformer game. The camera following the player worked fine, until I changed my world bounds to start at the bottom of the world and the player going up (first the world started at 0, 0). My player can jump, but the camera won't follow anymore. I've searched a lot about it but nothing could help me further. I'm just using:;Hope anyone can help!
  12. Hi, after upgrating to latest Phaser v2.1.3 performance in camera.follow rapidly drops... Here is a example... Test steps: - after load click on "HRAJ"("hraj" means "play" in slovak language) - you will be forced to fullscreen - use your keyboard arrows and walk around with character Whats wrong? When camera is moving with character performance of app rapidly drops!!! This is not a problem in Phaser 2.0.7 but all version up to 2.0.7 are affected with this Expected behaviour In phaser v2.1.3 it should camera.follow performance fast as it is in Phaser v2.0.7 CAMERA FOLLOW IS FAST - v2.0.7 This link using v2.0.7 - it's fast CAMERA FOLLOW IS EXTREMELY SLOW - v.2.1.3 This link load Phaser 2.1.3 - and on camera follow its extremely slow Code is the same but different versions of Phaser, any suggestions? Thanks for support
  13. Hi, I'm posting this because I've been doing a lot of searching and I can't seem to find a solution to this problem. I'm sorry if this is something generic that I've missed. The problem: When I start to move my player character, the character remains in the centre (good), but the tiled background doesn't scroll with the player. This means that the player can run and jump on platforms, but they are "invisible" as the background hasn't moved. I'm using a Tiled generated level in a platformer. The camera is following the player using -; The level was created in tiled, it uses a 200 x 200 image split into a grid of 20x20 tiles. The level itself is 64 x 40 tiles, so if the full resolution of the tiled level is 1280 x 800. The resolution of the main phaser game is 640 x 400. This means that the game should scroll in both x and y. I'm just doing this as a test so far and I may want to produce larger levels later. Does anyone have any clues as to why this might be happening? Thanks, Dan
  14. Hi, I'm new in the community and I love phaser JS. I'm developing a platform game. I like to comment my problem with "intelligence projectiles" I would mention to my problem with "smart missiles". Basically I do not know how to perform this task. I am able to handle sprites with animations but I do not know as provide them with "intelligence" to attack the player. I want the enemy attack the player shooting projectiles that follow. I attach a picture with my problem. Any idea? A greeting.
  15. Hi everyone, Does someone know how I could automatically follow all topics of a specific forum? I follow a forum, so I get notifications for all its new topics and for all topics for which I replied to but I am not notified when someone replies to a topic that I don't follow or for which I never replied to. I could manually click on "follow this topic" for every single new topic but let's say I would prefer something more automatic... Thanks for helping