Search the Community

Showing results for tags 'phaser'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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 3,231 results

  1. Physics problem

    Hi I've got a slight problem with the physics in the game and it only happens on one platform, but always on that platform. If the player dies there and they click the reset game button, the game registers a 'dead' to the console log immediately. It works everywhere else... So my question is, can I reset the physics (ARCADE PHYSICS by the way!) ? Appreciate it if anyone has had problems with this sort of thing or even just how to maybe do it another way! Thanks for the great framework!
  2. Gravity issue upgrading to 2.0.3

    Hi everyone, I'm going through a game I've been developing and updating it from v1.1.3 to v2.0.3, however I seem to have come across a small issue. After updating, the gravity on my player seems to act a lot differently than before. When updating I've enabled Arcade physics and enabled it on my player, when my player drops into the game now (with player.body.gravity.y set to 17 as before) it does so very slowly rather than dropping in at a normal speed. Also, when jumping, the player flies off into the sky rather than a short quick jump. Am I missing something or should I be using a different physics engine here? Thanks, Martin
  3. in function create(): create 15 cubes on the top of gameworld: stars = game.add.group();for (var i = 0; i < 15; i++) { var star = stars.create(375, -50, 'star'); game.physics.arcade.enable(star); star.enableBody = true; star.body.collideWorldBounds = true; star.body.immovable = true; }timer: game.time.events.loop(Phaser.Timer.SECOND, updateCounter, this);in function updateCounter, make the cubes fall down one by one: if(i<15){live = stars.getAt(i);live.body.immovable = false;live.body.gravity.y = GRAVITY;//live.body.velocity.y = 90;i++;}
  4. I'm using VS Express 2013 for the Web and following this tutorial: http://www.photonstorm.com/phaser/advanced-phaser-and-typescript-projects My code: Game.ts ///<reference path="phaser.d.ts"/>module Crazytopia { export class Game extends Phaser.Game { constructor() { super(1023, 630, Phaser.AUTO, 'content', null); this.state.add('Boot', Boot, false); this.state.add('Preloader', Preloader, false); this.state.add('Menu', Menu, false); this.state.add('Room_1', Room_1, false); this.state.start('Boot'); } }} Boot.ts module Crazytopia { export class Boot extends Phaser.State { preload() { this.load.image('preloadBar','img/loader.png'); } create() { this.input.maxPointers = 1; this.stage.disableVisibilityChange = true; if (this.game.device.desktop) { // If you have any desktop specific settings, they can go in here [b][color=#ff0000]this.stage.scale.pageAlignHorizontally = true;[/color][/b] } this.game.state.start('Preloader', true, false); } }} Menu.ts module Crazytopia { export class Menu extends Phaser.State { username: Phaser.Text; menuTitle: Phaser.Text; create() { //this.stage.setBackgroundColor(0x2d2d2d); this.menuTitle = this.add.text(this.world.centerX, this.world.centerY, 'Enter your name:', { font: "30px Arial", fill: "#ffffff", align: "center" }); this.menuTitle.anchor.setTo(0.5, 0.5); this.username = this.add.text(this.world.centerX, this.world.centerY + 70, '', { font: "30px Arial", fill: "#ffffff", align: "center" }); this.username.anchor.setTo(0.5, 0.5); this.input.keyboard.addCallbacks(this, this.keyboardHandler); if (this.input.keyboard.addKey(Phaser.Keyboard.P).justPressed()) { this.startGame; } } keyboardHandler( evt ) { // Skip it unless it's a-z. if (evt.which < "A".charCodeAt(0) || evt.which > "Z".charCodeAt(0)) { console.log("Not a letter: ", evt.which); return; } var letter = String.fromCharCode(evt.which); if (!evt.shiftKey) letter = letter.toLowerCase(); this.username.setText(this.username.text + letter); } startGame() { this.game.state.start('Room_1', true, false); } }} Note: there is also Preloader.ts, Room_1.ts and app.ts but I do not think they are relevant to the problem (please correct me if I'm wrong). The errors I get: Error 1 The property 'setTo' does not exist on value of type 'PIXI.Point' (Menu.ts ln 17)this.menuTitle.anchor.setTo(0.5, 0.5);Error 2 The property 'setTo' does not exist on value of type 'PIXI.Point' (Menu.ts ln 25)this.username.anchor.setTo(0.5, 0.5);Error 3 The property 'pageAlignHorizontally' does not exist on value of type 'PIXI.Point' (Boot.ts ln 14)this.stage.scale.pageAlignHorizontally = true;I'm new to Typescript and Phaser so I have no idea what I'm doing wrong. Thanks for reading!
  5. Hi guys, So I'm trying to expand the game I'm making to be a multiplayer game using Node.js and Socket.io. The connection between server-side and client-side is working, however I don't know how to update the positions of the players. This is how it goes, whenever a player moves the socket.sessionid and coordinates are send to the server. The server then broadcasts this data to all the other clients except the client which sent the data. In the client-side that information gets decoded and stored in 2 variables (at this moment), a player variable (with the id), and a X variable (with the x value, duh). At this moment I really don't know how to update the positions of a certain sprite in the game. Are there any examples on how to create a basic multiplayer Phaser game using websockets? I'm kinda stuck. The code I'm using on the client side is as follows, it is very dirty atm since I'm experimenting.. The 'xChanged' function sends the new position to the server, and 'posChanged' reads the data that gets sent from the server. var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, '', { preload: preload, create: create, update: update});function preload() { game.load.spritesheet('player', 'img/ally_sprite.png', 64, 64); game.load.image('boss', 'img/boss.png'); game.load.image('bullet', 'img/bullet.png');}var player, boss, cursors, x, y, z, xTouch, yTouch, fireButton, bullets, bulletTime = 50, text, bulletsCount = 30;var players = {};var io = io.connect('http://192.168.0.13:3000');// server ipvar xPos, yPos, label, sock;function create() { game.renderer.clearBeforeRender = false; game.renderer.roundPixels = true; game.physics.startSystem(Phaser.Physics.ARCADE); player = game.add.sprite(game.world.centerX, game.world.centerY, 'player'); player.anchor.setTo(.5,.5); player.animations.add('fly'); player.animations.play('fly', 10, true); game.physics.enable(player, Phaser.Physics.ARCADE); player.enableBody = true; player.body.collideWorldBounds = true; // new player var pos = JSON.stringify({ player: io.socket.sessionid, x: game.world.centerX, y: game.world.centerY, angle: 0 }); socket.emit('newPos', pos); boss = game.add.sprite(game.centerX, game.centerY, 'boss'); boss.enableBody = true; boss.physicsBodyType = Phaser.Physics.ARCADE; bullets = game.add.group(); bullets.enableBody = true; bullets.physicsBodyType = Phaser.Physics.ARCADE; bullets.createMultiple(30, 'bullet'); bullets.setAll('anchor.x', 0.5); bullets.setAll('anchor.y', 1); bullets.setAll('outOfBoundsKill', true); game.stage.backgroundColor = '#ccc'; game.input.addPointer(); fireButton = game.input.pointer1; if(isMobile.any) { if(gyro.hasFeature('devicemotion')) { console.log('gyrojs loaded'); if(gyro.getFeatures().length > 0) { gyro.frequency = 10; gyro.startTracking(function(o) { var anglePlayer = Math.atan2(o.y, o.x); angleRadians = anglePlayer * Math.PI/180; anglePlayer *= 180/Math.PI; anglePlayer = 180 - anglePlayer; player.angle = game.math.wrapAngle(anglePlayer, false); if(fireButton.isDown) { fire(); } if(o.z < 9.5 || o.z > 10) { player.body.velocity.x -= o.x * 20; player.body.velocity.y += o.y * 20; } else { player.angle = 0; } console.log(player.body.velocity.x); // Send new position to server var newPos = JSON.stringify({ player: io.socket.sessionid, x: player.body.velocity.x, y: player.body.velocity.y, angle: player.angle }); socket.emit('newPos', newPos); }); } } else { // fallback als gyro.js niet werkt.. console.log('gyrojs not loaded'); window.addEventListener('devicemotion', function(event) { x = event.accelerationIncludingGravity.x; y = event.accelerationIncludingGravity.y; z = event.accelerationIncludingGravity.z; var anglePlayer = Math.atan2(y, x); anglePlayer *= 180/Math.PI; anglePlayer = 180 - anglePlayer; player.angle = game.math.wrapAngle(anglePlayer, false); if(fireButton.isDown) { fire(); } if(z < 9.5 || z > 10) { player.body.velocity.x -= x * 40; player.body.velocity.y += y * 40; } else { player.angle = 0; } // Send new position to server var newPos = JSON.stringify({ player: io.socket.sessionid, x: player.body.velocity.x, y: player.body.velocity.y, angle: player.angle }); socket.emit('newPos', newPos); var interval = 10; }); } } else { // Niet mobiel, bewegingen omzetten in keys console.log('Niet Mobiel'); cursors = game.input.keyboard.createCursorKeys(); } text = game.add.text(game.world.centerX, 50, "Bullets: 30", { font: "65px Arial", fill: "#000000", align: "center" }); text.anchor.setTo(0.5, 0.5); // Add new players to the screen socket.on('newPlayerwithPos', function(data) { var obj = JSON.parse(data); var xNew = obj.x; var yNew = obj.y; console.log(xNew, yNew); var p = game.add.sprite(xNew, yNew, 'player'); p.anchor.setTo(.5,.5); p.animations.add('fly'); p.animations.play('fly', 10, true); game.physics.enable(p, Phaser.Physics.ARCADE); p.enableBody = true; p.body.collideWorldBounds = true; });}function update() { player.body.velocity.setTo(0,0); if(!isMobile.any) { if(cursors.left.isDown) { player.body.velocity.x -= 40; } else if(cursors.right.isDown) { player.body.velocity.x += 40; var newPos = JSON.stringify({ x: player.x, player: io.socket.sessionid }); } if(game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR).isDown) { fire(); } } // Get new positions from all other players socket.on('updatePos', function(data) { for(var playerData in data) { // update array of players var player = {}; player.name = data[playerData].sessionID; player.x = data[playerData].x; player.y = data[playerData].y; player.angle = data[playerData].angle; players[player.name] = player; } }); // loop through all players and draw sprites for(var playerData in players) { var p = ''; var playerX = players[playerData].x; var playerY = players[playerData].y; var playerAngle = players[playerData].angle; var p = game.add.sprite(playerX, playerY, 'player'); game.physics.enable(p, Phaser.Physics.ARCADE); p.enableBody = true; p.body.velocity.x -= playerX; p.body.velocity..y += playerY; p.angle = playerAngle; }}function fire() { if(game.time.now > bulletTime) { bullet = bullets.getFirstExists(false); if(bullet) { bullet.reset(player.body.x + 32, player.body.y + 32); bullet.rotation = player.rotation; game.physics.arcade.velocityFromRotation(player.rotation, 400, bullet.body.velocity); bulletTime = game.time.now + 50; // Update bullet counter bulletsCount --; text.setText("Bullets: " + bulletsCount); } }}
  6. I recently made a game with phaser and noticed that when I press down key the page goes down. Similarly the same happens with up key. Even space key makes the page scroll down. The game gets the keys and works the way it should work but the page also scrolls. This totally ruins the fun. How to handle this situation???
  7. [Phaser] Simple Shooter Game

    After knowing about lessmilk, I got so inspired that I too have decided to create a game a week. Atleast I would try to achieve that Here is my first game in this series. It's a very basic simple shooter game made with some free art. I have used Phaser for this game. This may not be a good game but I wanted to atleast begin making games to get the confidence to make more games. The code is available on github. I hope beginners can use it for learning purpose. Play it here http://suyashmohan.github.io/Space-Shooter/
  8. [WIP][Phaser] Moon

    Moon is a my first Phaser game... well if I'm entirely honest its pretty much the first proper game I have ever made other than a few experiments here and there. It is a take on the classic Lunar Lander. Its intended for mobiles primarily, and is by no means completely finished. I need to add sound, a loading bar, iron out a few bugs, and add a lot of polish to menus and instructions etc but it is coming along nicely. I am also considering implementing gyroscope controls if possible, but we will have to see how that goes It is pretty hard, I know, and I have actually been slowly decreasing the difficulty although I want to avoid making it too easy. I have used p2 for physics so it is a little performance heavy, but I have tested it on an iPhone 5, iPad mini, iPad 3rd gen, and HTC One all at 60fps so I am fairly pleased. On a very old and clogged up iPhone 4 it was still getting 30+ so not too bad. Anyway you can play it here: Moon I would love to hear what you think, and if you have any suggestion or discover a bug please let me know! Likewise if you have any questions about the game fire away
  9. I am considering getting started with Phaser. I might like to use it in LD29 next weekend. I had question about the performance of geometry in Phaser. When tinkering with the circle geometry example, I set the rendering mode to WebGL. I noticed that basic animations on the circle made it very choppy. I thought that WebGL was typically more performant compared to 2D canvas. Is this only true for displaying raster graphics, or should it apply to generated geometry as well? Just want to make sure this situation wasn't an anomaly for my system. If working with rectangles, circles, lines, and points is meant for 2D canvas, that is fine, I just want to prepare for that going in so that I can get the best performance possible. Thank you in advance for any answers!
  10. Hi there, I´m trying to find something about this but... not working. Anyway, I have two tweens on my game and I need to do that with Phaser.Easing.Elastic.InOut Everything is cool, the only problem is that the "elasticity" is tooo much, I want the animation being elastic but not so much, how can I control that? I don´t know how to use the "example" in the documentation... InOut(k) → {number} Thanks in advance mates!
  11. Method to clone a sprite?

    Is there a method to clone/duplicate a sprite?
  12. [Phaser] Brickety Split

    My first HTML5 game, made in Phaser, has been entered in the clay.io "Got Game?" contest for student game developers. If you play it and take the time to leave a rating or review, you directly help my chances of winning, so please play it and rate if you enjoy. Brickety Split The game is about building the tallest wall you can by avoiding bricks that fall from the sky as enemies attempt to trap you. I wrote a detailed post-mortem of my development process. You can read it on my website: http://nathanielnelson.com/brickety-split-release-post-mortem/ And if you have any feedback, please share it. I'm still updating the game and adding suggestions (within reason).
  13. Treedle

    Treedle is a game about lumbering. Player has to chop trees by clicking on them. There are some upgrades and achievements. Play it here: http://treedle.clay.io/ Overview page: http://clay.io/game/treedle Any feedback appreciated! Thanks for your support!
  14. Help With Tilemaps And Tilesets

    I need help with creating tilemaps. I use tiled to create the maps, however it seems that tiled is counting my tileset image starting at 1, while phaser counts tilesets starting from 0. Because of this, whenever I make a tilemap, the blocks are out of order, and the map looks all screwey. Please help, I have attached an image to better explain this:
  15. Pass parameter to button callback

    Hi there, I'm trying to do something which I think should be rather simple but I don't seem to be able to achieve it. When a button is clicked, I'm trying to pass a parameter to the button callback function, however if I pass anything to the function and console.log it out, it's always the clicked button. Is there a way to pass a parameter other than the button to the button callback? Thanks! Martin
  16. Failed to execute 'decodeAudioData' on 'AudioContext'

    I've followed the directions on photonstorm's website the best i could to play audio whenever the world restarts. (This is a mod of a flappy bird project). the console reads: Phaser.StateManager - No state found with the key: main_state phaser.min.js:4Uncaught SyntaxError: Failed to execute 'decodeAudioData' on 'AudioContext': invalid ArrayBuffer for audioData. phaser.min.js:10My main.js: /*jslint node: true */"use strict";var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game_div');var sfx = Phaser.Sound;var main_state = { preload: function () { this.game.stage.backgroundColor = '#71c5cf'; this.game.load.image('george', 'assets/george.png'); this.game.load.image('pipe', 'assets/pipe.png'); this.game.load.audio('sfx', 'assets/music.mp3'); }, create: function () { /*AUDIO*/ var sfx = game.add.audio('sfx'); /*SPRITES & MECHANICS*/ this.george = this.game.add.sprite(100, 245, 'george'); this.george.body.gravity.y = 1000; var space_key = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); space_key.onDown.add(this.jump, this); this.pipes = game.add.group(); this.pipes.createMultiple(20, 'pipe'); this.timer = this.game.time.events.loop(1500, this.add_row_of_pipes, this); this.score = -1; var style = { font: "30px Arial", fill: "#ffffff" }; this.label_score = this.game.add.text(20, 20, "Score = 0", style); this.game.state.start('main_state'); }, update: function () { if (this.george.inWorld === false){ this.restart_game(); } this.game.physics.overlap(this.george, this.pipes, this.restart_game, null, this); }, jump: function () { this.george.body.velocity.y = -350; }, restart_game: function () { this.game.time.events.remove(this.timer); this.game.state.start('main'); sfx.play(); }, add_one_pipe: function (x, y) { var pipe = this.pipes.getFirstDead(); pipe.reset(x, y); pipe.body.velocity.x = -200; pipe.outOfBoundsKill = true; }, add_row_of_pipes: function () { var hole = Math.floor(Math.random() * 5) + 1; for (var i = 0; i < 8; i++){ if (i != hole && i != hole +1) this.add_one_pipe(400, i*60+10); } this.score += 1; this.label_score.content = 'Score = ' + this.score; },};game.state.add('main', main_state);game.state.start('main');
  17. Game.Camera.follow Speed Increase

    I'm teaching myself how to use Phaser, and up until today, I've been using a very rudimentary method for keeping the camera focused on my player ingame. What I had in my update() function was: game.camera.y = player.y - 200;game.camera.x = player.x - 500;But recently I discovered the game.camera.follow function. When I call game.camera.follow(player);in the update() function instead of the previous two lines, my game is sped up greatly. You can see what I mean here: Hacky Camera follow: http://michaelbell.ca/Phased-Game/camera-debug/hacky/ Game.camera.follow: http://michaelbell.ca/Phased-Game/camera-debug/game-camera-follow/ Arrow keys to move, when you perform a double jump(up arrow, then another up arrow while in the air), he spins, only in the second link, he spins much faster, and the only code I changed is the camera follow code. Anyways, I would like to know why the game sped up so much when I used the new code, and how can I tell if a line of code is very inefficient
  18. Error: Sound.destroy

    Hi, I've been making my first game in Phaser (using Phaser 2.0.3) and have been looking to ensure that some sounds are garbage collected when they are no longer in use. I was hoping to use Sound.destroy to do so (which I think is a new feature to Phaser 2.0.3)/ However, when I call Sound.destroy, I am getting the following error (as pasted below from Chrome's console): I get the same error in all browsers tested (Chrome and Firefox). Has anyone else encountered this issue? Thanks!
  19. I stumbled upon an awkward issue with my game this morning. I wanted to see how my game performed on multiple browsers and I found that IE11 placed an awkward "Brightened" effect to my game. There is a screenshot below and the game link is here. I found no errors in the JavaScript console. How could this be happening?
  20. Inspired by Thomas Palef (lessmilk) and Luis Felipe Ocampo, I will be making one HTML5 game per week, in order to learn how to code games using the Phaser framework. I’ve been making demos and tests in my free time for almost a month, but never finished a real game, and I think it’s the right time to do it. All my games at gikdew.com Check my games, share them and give me some feedback, you can also my blog posts about game development and how I develope my one week games! Game #4 - Wriggle Worm Play here! Game #3 - Fast Racing Play here! Game #2 - Cloud Wars Play here! Game #1 - Circula Play here!
  21. Deleting off camera group items

    I'm still figuring out Phaser, and I've made a mario clone that involves shooting bullets at enemies. I'm trying to destroy the bullets after they leave the camera view, but I'm having some troubles. I have tried using bullet = bullets.create(player.x, player.y+8, 'bullet'); bullet.events.onOutOfBounds.add( goodbye, this ); function goodbye(obj) { console.log(obj); obj.kill(); } Howevery, this never fires, even after the bullet has left the camera. I think that it might be because my world bounds are much larger than the camera is, so I tried making a function to destroy the bullets after they leave the camera like this: function checkBullet(){ bullets.forEach(function(item) { if(item.inCamera===false){ item.kill() } });} However this kills the bullets immediatly, which I also don't want. Is there a better way that I can go about this that will actually work?
  22. Creating A Ragdoll In Phaser

    So I'm trying to create a rag doll based game, where the user dodges some falling objects! It's inspired by one of my favorite games as a kid: http://www.freewebarcade.com/game/ragdoll-avalanche-2/ There isn't really any documentation on this and frankly I'm pretty new to game development(not javascript though) Whats the easiest way to get a ragdoll running in phaser? I was able to find a vague reference leading to P2JS and its ragdoll example but: 1. I'm not skilled enough port it to phasers built in P2 2. The ragdoll isn't very similar to the one in ragdoll avalanche Is there a way to do this with sprites & maybe physics editor to get it running more the like example game I provided? Any help / example code you'd be willing to share is greatly appreciated! -Thanks for reading
  23. [Phaser] ProTrader 3000

    Last week I created a kind of Stock Market parody game. You can watch the news to know if you should sell, buy or short the share. There is only one kind of paper: Money (MNY). Your currency is Cash. You have 2 minutes to make as much as profit as you can. The game is not fully complete, I want to add more News to the TV. Play it here: http://svejkgames.com/game/protrader3000
  24. Music Loading issue

    Hey Everyone So I have an issue. I'm currently loading music at my load screen as seen below: if (this.ready===true && this.cache.isSoundDecoded('someChords') ) { //this.ready=true; //hide loading css document.getElementById('ball').style.display = 'none'; //show game document.getElementById('tapjuggler-game').style.display = 'block'; this.game.state.start('menu'); } However, I'm finding that its taking forever on mobile devices (PC seems fine). I'm trying my best to troubleshoot the problem but I'm completely unsure of what to do. Is the file too big? Is there another way to "wait" for the file to start playing before moving to the next scene? Any help would be appreciated.
  25. So, this weekend I finish the design of my new game. I managed to go from here: to here: what do you think about my progress?? Do you like the new design??