bloodbarron115

Members
  • Content Count

    11
  • Joined

  • Last visited

  1. bloodbarron115

    Sound

    I am having a hard time figuring out the new docs system for Phaser and am fairly new to it in general and can't figure out how to add sound into my game or use sound in general. I'd really love some help
  2. bloodbarron115

    Sound

    I am having a hard time figuring out the new docs system for Phaser and am fairly new to it in general and can't figure out how to add sound into my game or use sound in general. I'd really love some help
  3. How would I make an event occur when I drag and drop an object onto another object?
  4. How do I make a variable equivalent to a number chosen by the player via pressing the key on the keyboard?
  5. I need these 2 variables: newEquation: function () { var x = Math.floor(Math.random() * (10 - 1)) + 1; var y = Math.floor(Math.random() * (10 - 1)) + 1;} to be defined in this if statement: update: function () { if (myInput == x + y) { this.correct(); } else { this.wrong() }}, While staying in the newEquation funciton
  6. I have 3 opponents spawning in and occasionally they spawn on eachother. How can I have it check if an opponent has already spawned there? for(var i=0; i<3; i++) {opponent = this.createOpponents();} createOpponents: function () {var rndPlace = Math.floor(Math.random() * (188 - 0)) + 0;opponent = this.game.add.sprite(0, rndPlace, 'enemy');this.game.physics.enable(opponent, Phaser.Physics.ARCADE);var rndVel = Math.floor(Math.random() * (10 - 5)) + 5;opponent.body.velocity.x = rndVel;return opponent;}
  7. bloodbarron115

    Input

    I'm working on making a math game for kids and I am unsure of how to make the math problems appear on the screen and then making it so the keyboard can be used to answer the question. Any help would be greatly appreciated.
  8. How do I give the properties set in this function: function createFlake() {flake = game.add.sprite(100, 0, 'flake');game.physics.enable(flake, Phaser.Physics.ARCADE);flake.body.velocity.y = 100;flake.checkWorldBounds = true;flake.body.collideWorldBounds = true;return flake;} To the members of the first array: var snowTracker = { snowFalling:[100],snowOnGround:[100],} I don't know if this will help in any attempts to help me but In the end i want the array flakes to fall from the sky and stack on eachother
  9. I have a snow plow that spawns in when the snow reaches a certain point. When the snow reaches said point the snow falling goes back to its start point and continues falling. When the snowplow spawns it goes across the screen until the snow reaches the point again. My problem is that the snow plow doesn't push the snow when it goes across the screen. I've been stuck for a hours trying to solve this and I can't.
  10. I tried using immovable but all it did was cause the fish to stop bouncing when it made contact with the wall. Do you have any other suggestions?
  11. I am currently making my first game in phaser, where a fish bounces around the screen and eats fish that you spawn in yourself. I am having 2 issues. First off when he bounces off the walls the walls move and occasionally disappear and also when you spawn more than one fish only the most recent fish will be eaten. Here's my code: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /><title>Fishtank Game</title><script type="text/javascript" src="js/phaser.min.js"></script> <style type="text/css"> body { margin: 0; } </style></head><body> <script type="text/javascript"> var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); function preload() {game.load.image('water', 'assets/water1.png');game.load.image('fish', 'assets/fish.png');game.load.image('wall', 'assets/hidden wall.png');game.load.image('wall2', 'assets/wall flipped.png');game.load.image('smallfish', 'assets/smallfish.png'); var begin = true; var fish;var wallRight;var wallLeft;var smallFish; var createKey; //var fishAngles = ['-100', '100', '-150', '150', '-200', '200', '-250', '250', '-300', '300'];//var angle = fishAngles[Math.floor(Math.random()*fishAngles.length)]; } function create() { smallFish = 'smallfish'; createKey = game.input.keyboard.addKey(Phaser.Keyboard. ; game.physics.startSystem(Phaser.Physics.ARCADE); game.physics.arcade.checkCollision.down = true; game.add.sprite(0,0, 'water'); wallRight = game.add.sprite(799, 0, 'wall'); game.physics.enable(wallRight, Phaser.Physics.ARCADE); wallRight.body.bounce.set(1); wallLeft = game.add.sprite(-80, 0, 'wall'); game.physics.enable(wallLeft, Phaser.Physics.ARCADE); wallLeft.body.bounce.set(1); ceiling = game.add.sprite(0, -80, 'wall2'); game.physics.enable(ceiling, Phaser.Physics.ARCADE); ceiling.body.bounce.set(1); floor = game.add.sprite(0, 599, 'wall2'); game.physics.enable(floor, Phaser.Physics.ARCADE); floor.body.bounce.set(1); fish = game.add.sprite(0, 250, 'fish');fish.anchor.set(0.5);fish.checkWorldBounds = true; game.physics.enable(fish, Phaser.Physics.ARCADE); fish.body.collideWorldBounds = true;fish.body.bounce.set(1); game.input.onDown.add(releasefish, this); createKey.onDown.add(creation, this); } function creation () { smallFish = game.add.sprite(300, 400, 'smallfish');smallFish.anchor.set(0.5);smallFish.checkWorldBounds = true; game.physics.enable(smallFish, Phaser.Physics.ARCADE); smallFish.body.collideWorldBounds = true;smallFish.body.bounce.set(1); smallFish.body.velocity.x = 300;smallFish.body.velocity.y = 400;} function releasefish () { if(begin = true){begin = false;fish.body.velocity.y = -500 - Math.random();fish.body.velocity.x = -300 - Math.random(); wallLeft.x = -79;wallRight.x = 799;ceiling.y = -80;floor.y = 599;}} function update() { game.physics.arcade.collide(fish, wallRight, fishHitRight, null, this);game.physics.arcade.collide(fish, wallLeft, fishHitLeft, null, this);game.physics.arcade.collide(fish, ceiling, fishHitCeiling, null, this);game.physics.arcade.collide(fish, floor, fishHitFloor, null, this); game.physics.arcade.collide(smallFish, wallRight, smallFishHitRight, null, this);game.physics.arcade.collide(smallFish, wallLeft, smallFishHitLeft, null, this);//game.physics.arcade.collide(smallFish, ceiling, smallFishHitCeiling, null, this);//game.physics.arcade.collide(smallFish, floor, smallFishHitFloor, null, this); game.physics.arcade.collide(fish, smallFish, eating, null, this);} function fishHitRight() { var diff = 0; fish.scale.x = -1;wallLeft.x = -80;ceiling.y = -80;floor.y = 599; if (fish.y < wallRight.y) { diff = wallRight.y - fish.y; fish.body.velocity.y = (-2 * diff + Math.random()); }else if (fish.y > wallRight.y) { diff = fish.y - wallRight.y; fish.body.velocity.y = (2 * diff - Math.random()); }else { fish.body.velocity.y = 2 + Math.random() * 12; }} function fishHitLeft() { var diff = 0; fish.scale.x = 1;wallRight.x = 799;ceiling.y = -80;floor.y = 599; if (fish.y < wallLeft.y) { diff = wallLeft.y - fish.y; fish.body.velocity.y = (2 * diff - Math.random()); }else if (fish.y > wallLeft.y) { diff = fish.y - wallLeft.y; fish.body.velocity.y = (-2 * diff + Math.random()); }else { fish.body.velocity.y = 2 + Math.random() * 12; } } function fishHitCeiling() { var diff = 0; wallLeft.x = -80;wallRight.x = 799;floor.y = 599; if (fish.x < ceiling.x) { diff = ceiling.x - fish.x; fish.body.velocity.x = (-2 * diff + Math.random()); }else if (fish.x > ceiling.x) { diff = fish.x - ceiling.x; fish.body.velocity.x = (2 * diff - Math.random()); }else { fish.body.velocity.x = 2 + Math.random() * 12; }} function fishHitFloor() { var diff = 0; wallLeft.x = -80;wallRight.x = 799;ceiling.y = -80; if (fish.x < floor.x) { diff = floor.x - fish.x; fish.body.velocity.x = (-2 * diff + Math.random()); }else if (fish.x > floor.x) { diff = fish.x - floor.x; fish.body.velocity.x = (2 * diff - Math.random()); }else { fish.body.velocity.x = 2 + Math.random() * 12; }} function smallFishHitRight() { smallFish.scale.x = -1;wallLeft.x = -80;} function smallFishHitLeft() { smallFish.scale.x = 1;wallRight.x = 799; } function eating(fish, smallfish) { smallFish.kill();} </script> </body></html>