RoyOBannon

Members
  • Content count

    5
  • Joined

  • Last visited

About RoyOBannon

  • Rank
    Newbie
  • Birthday March 25

Profile Information

  • Gender
    Male
  1. couple of questions

    I've found all my mistakes. Thanks to everybody.
  2. couple of questions

    var game = new Phaser.Game(1024,768,Phaser.AUTO, 'space game', {preload: preload, create: create, update: update}); var ships; var ship; function preload(){ game.load.image('spaceship', 'assets/spaceship_sprite.png'); game.load.image('menu', 'assets/menu.png'); } function create(){ ship = game.add.sprite(500,680, 'spaceship'); game.physics.arcade.enable(ship); ship.scale.setTo(0.5,0.5); //ship2 = myship(game, 'spaceship', 600, 200); ships = game.add.group(); for (var i = 0; i < 0; i++){ //var sx = 100; ships.create(600, 200, 'spaceship'); //myship(game, 'spaceship', 500+sx, 200); //sx += 100; //game.add.sprite(500, 200, 'spaceship'); } cursors = game.input.keyboard.createCursorKeys(); pauseKey = game.input.keyboard.addKey(Phaser.Keyboard.ONE); pauseKey.onDown.add(addMenu, this); game.input.keyboard.removeKeyCapture(Phaser.Keyboard.ONE); } function update(){ if(cursors.left.isDown){ ship.body.x += -7; } if(cursors.right.isDown){ ship.body.x += 7; } } function addMenu(){ game.add.sprite(100,100,'menu'); } 1. I want to add a few sprites of a ship into the 'ships' group. But for loop doesn't work. I'm folowing this example: https://phaser.io/examples/v2/groups/add-a-sprite-to-group#gv even If I try to add object from external script. I've tried to create a few ships of 'myship' without the 'for loop' and it works fine. 2. If I uncomment this line: //ship2 = myship(game, 'spaceship', 600, 200), my 'ship' doesn't move (key input doesn't work). What am I doing wrong? Sorry for my poor english.
  3. Sublime Text plugin for auto completion Phaser API and more

    Dosen't work. I get a pop up menu with "game" after "Phaser. "
  4. fillStyle affects on a few objects

    Thank you! I even didn't know that I also can use "red", "black", or change my color to something like "rgba(0, 0, 255, 0.5)". I'm very new to js.
  5. Hello, guys could you explain it to me, why does the fillStyle in the drawPlayer function affects the grid too? var canvas = document.getElementById("MyCanvas"); var ctx = canvas.getContext("2d"); function drawGrid() { for (var i = 0; i <= canvas.width; i = i + 32){ ctx.beginPath(); ctx.rect(0+i, 0, 2, canvas.height); ctx.fillStyle = "#F620"; ctx.fill(); ctx.closePath(); } for (var j = 0; j <= canvas.height; j = j + 32){ ctx.beginPath(); ctx.rect(0, 0+j,canvas.width, 2); ctx.fillStyle = "#F620"; ctx.fill(); ctx.closePath(); } } function drawPlayer(){ ctx.beginPath(); ctx.rect(2, 2, 30, 30); ctx.fillStyle = "#F40"; ctx.fill(); ctx.closePath(); } function draw() { ctx.clearRect(0, 0, canvas.width, canvas.height); drawGrid(); drawPlayer(); } setInterval(draw, 10);