jjwallace

Members
  • Content Count

    146
  • Joined

  • Last visited

Everything posted by jjwallace

  1. Oops my mistake, that code isnt part of the problem, i forgot to rewrite the error... fixed
  2. This might be a stupid question but for some reason, my brain is broken today. I have a game state that adds a new object and calls a function on it. BasicGame.Game.prototype = { create: function () { var levelController = new LevelController(this, playerType); var playerType = 3; levelController.makePlayer(playerType); }, createPlayer: function (playerType) { console.log('Player ' + playerType + ' created'); } } I want to access a function from game state. var LevelController = function (superThis) {}; LevelController.prototype = {} LevelController.prototype.makePlayer= function(superThis, playerType){ superThis.createPlayer(superThis, playerType){ } Uncaught TypeError: BasicGame.Game.makePlayer is not a function at creatPlayer
  3. Cool, just got grunt working and i love it!
  4. Which uglifyJS methods do you use to protect your code?
  5. audio.volume = 0; EXAMPLE: https://phaser.io/examples/v2/audio/play-music
  6. Not Atlas? this.load.atlas('spJellyFish', 'assets/sprite/sp_jellyfish.png', 'assets/sprite/sp_jellyfish.json', Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
  7. How do i account for the android/iphone bar throwing off my game?
  8. Hello, What is your budget? I build games for Nickelodeon, USArmy, Fox and Heinlein PM me for details, must have a market priced budget.
  9. What are you building with rope?
  10. Not a possible solution because i need the range 1 - 180 and -1 - -180 to be aligned with surface for physics calculations.
  11. You need to set the anchor point this.fishBody = game.add.sprite(x, y, 'spFish'); this.fishBody.anchor.set(0.5,0.5); Also '.angle' is degrees and '.rotation' is radians
  12. Hello, I am building an Oceanic game and need to utilize the water surface. I am swimming fish through the sea however at angle '0' I want to fish to be pointing up and not left. I do this by creating the angle 90 degrees: this.xSpeed = Math.cos((this.fishBody.angle+90)/180*Math.PI) * -this.pSpeed; this.ySpeed = Math.sin((this.fishBody.angle+90)/180*Math.PI) * - this.pSpeed; However, I run into problems down the road with AI Fish.prototype.avoid = function(fishBodx, FishBodY, xsp,ysp){ var targetAngle = this.game.math.angleBetween( xsp, ysp, fishBodx, FishBodY ); if (this.fishBody.rotation !== targetAngle) { var delta = (targetAngle) - (this.fishBody.rotation); this.TURN_RATE = 3; // Keep it in range from -180 to 180 to make the most efficient turns. if (delta > Math.PI) delta -= Math.PI * 2; if (delta < -Math.PI) delta += Math.PI * 2; if (delta > 0) { // Turn clockwise this.fishBody.angle += this.TURN_RATE; } else { // Turn counter-clockwise this.fishBody.angle -= this.TURN_RATE; } // Just set angle to target angle if they are close if (Math.abs(delta) < this.game.math.degToRad(this.TURN_RATE)) { this.fishBody.rotation = targetAngle; } } } What is a good solution to this?
  13. I know this is an old thread but did this end up leading to anything cool?
  14. Who is at GDC? SLACK: https://html5gdc2017.slack.com/shared_invite/MTQ3MTk1MjQ3MTI0LTE0ODgyMjY4MDMtZjNmMmJjYTkzOA My Email: JJaywallace aaaaattt gmail dooot com
  15. jjwallace

    GDC 2017

    I am at GDC, hit me up jjaywallace aat gmail.com
  16. Hi guys, I am building a multiplayer game in Phaser. I want to add a UI button that builds a QR code so other people can scan the laptop or cell phone and join right into the game. Has any of you implemented QR code generation into any of your games and if so would you like to share how you did it. I will attempt today and post what I end up using.
  17. Hi guys, I am building a multiplayer game in Phaser. I want to add a UI button that builds a QR code so other people can scan the laptop or cell phone and join right into the game. Has any of you implemented QR code generation into any of your games and if so would you like to share how you did it. I will attempt today and post what I end up using.
  18. Hi guys, I am making an app that overlays a png over a video. I want the user to insert their face via webcam or upload. How do i allow user to upload image to phaser? Is it possible to use webcam? I am also building resize image UI, unless there is already one.
  19. When you create a game object do sprites inside its create class automatically become children of that class? Frome Examples: MonsterBunny = function (game, rotateSpeed) { // We call the Phaser.Sprite passing in the game reference // We're giving it a random X/Y position here, just for the sake of this demo - you could also pass the x/y in the constructor Phaser.Sprite.call(this, game, game.world.randomX, game.world.randomY, 'bunny'); this.anchor.setTo(0.5, 0.5); this.rotateSpeed = rotateSpeed; var randomScale = 0.1 + Math.random(); this.scale.setTo(randomScale, randomScale) game.add.existing(this); }; MonsterBunny.prototype = Object.create(Phaser.Sprite.prototype); MonsterBunny.prototype.constructor = MonsterBunny; MonsterBunny.prototype.update = function() { // Automatically called by World.update this.angle += this.rotateSpeed; }; var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); function preload() { game.load.image('bunny', 'assets/sprites/bunny.png'); } function create() { for (var i = 0.1; i < 2; i += 0.1) { new MonsterBunny(game, i); } }
  20. Hi guys, I have a socket.io server running with node.js and i am trying to add players/sprites to my game. I am trying to figure out the best way to do this. As of now i have been working towards using object arrays but i know this is a better way. socket.on('addPlayer',function(data){ var thisID = data;//myArrayID; if(data.id == myID){ }else{ console.log(thisID); pFish[thisID] = this.add.sprite(); pFish[thisID].x = this.world.centerX; pFish[thisID].y = this.world.centerY; pFish[thisID].anchor.setTo(0.5, 0.5); pMouth[thisID] = this.add.sprite(0, 0, 'spMouth'); pMouth[thisID].anchor.setTo(0.5, 1); pMouth[thisID].animations.add('eat'); pMouth[thisID].animations.play('eat', 30, true); pTail[thisID] = this.add.sprite(0, 0, 'spTail'); pTail[thisID].anchor.setTo(0.5, 0); pTail[thisID].animations.add('swim'); pTail[thisID].animations.play('swim', 30, true); pTail[thisID].y = spMouth.y - 12; pFish[thisID].addChild(spMouth[thisID]); pFish[thisID].addChild(spTail[thisID]); pFish[thisID].scale.setTo(0.2, 0.2); pFish[thisID].angle = 110; } }) So what i really want to do is add a player object. This way i can have all 3 sprites inside the object and i can just change the object. Of course i will need to update each player with the corisponding input comming in from the server. Any good examples of how to do this in a OOP method for Phaser.? Example: BasicGame.Game.prototype = { preload: function () { //this.load.script('io', 'node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js'); //console.log('NODE LOADED'); }, create: function () {
  21. Uncaught ReferenceError: map1 is not defined For the life of me cannot find out why map1 is not found var map; var coins; var layer; var sprite; BasicGame.Game3.prototype = { create: function () { console.log('Game Launched'); this.camera.flash('#006600'); this.loadVars() this.loadLevel(); this.renderGame(); //this.input.onDown.add(this.fire, this); }, fire: function () { }, loadVars: function(){ }, loadLevel: function(){ this.load.tilemap('map1', 'assets/lvl/collision_tests.json', null, Phaser.Tilemap.TILED_JSON); this.load.image('ground_1x1', 'assets/tiles/ground_1x1.png'); this.load.image('walls_1x2', 'assets/tiles/walls_1x2.png'); this.load.image('tiles2', 'assets/tiles/tiles2.png'); // this.load.tileset('ground_1x1', '/assets/tiles/ground_1x1.png', 72, 72); // this.load.tileset('walls_1x2', '/assets/tiles/walls_1x2.png', 72, 72); // this.load.tileset('tiles2', '/assets/tiles/tiles2.png', 72, 72); }, renderGame: function() { console.log(map1); map = this.add.tilemap('map1'); <<<<< ERROR IS HERE!!!!!!!!!!!!!!!!!!!! console.log('Map loaded');
  22. You have to unload the instance of the game. You can encapsulate everything and just destroy it if you want. Sometimes with grunt and angular you will get a double instance of your game also its kinda a pain. Have you tried just destroying the instance of the game and loading another one?