Jessicaward25

Members
  • Content Count

    11
  • Joined

  • Last visited

About Jessicaward25

  • Rank
    Member

Recent Profile Visitors

579 profile views
  1. Thanks So what would I replace game.add.sprite with? We tried just incrementing the X position, but then no matter what we did we couldn't get gravity to work, so would there be another way of moving the sprite?
  2. I've tried removing every feature that I can to make it not lag, but it still lags.. It seems to be ok when you start it up, but then after about 15 seconds or so the framerate drops. Somebody suggested it may be because the update() loop has many game.add.sprite lines.. But whenever the loop starts again the sprites are removed, which is what always happened in XNA? This is the code: http://pastebin.com/VtNUpxYu Thank you in advance!
  3. I have a player sprite, and a platform sprite.. I want the player to be affected by gravity, but not the platform. Here's the code that I have now.. game.physics.arcade.gravity.y = 500;But is there a way to set it so it's just player affected by it? Something like this? player.gravity = 500;
  4. Ok, so I want to add gravity to a sprite.. CreateGame function game.physics.startSystem(Phaser.Physics.ARCADE);player = game.add.sprite(400, 400, 'playerImage');game.physics.arcade.enable(player, Phaser.Physics.ARCADE);player.enableBody = true;player.collideWorldBounds = true;player.body.velocity.setTo(200, 200);player.body.setSize(20, 32, 5, 16);player.body.bounce.set(0.8);game.physics.arcade.gravity.y = 250;Update/Draw function game.world.removeAll();game.add.sprite(player.x, player.y, 'playerImage');Does the "game.add.sprite(player.x, player.y, 'playerImage);" line add a completely new sprite? I've noticed in the update function it draws the player at player.x and player.y... But the gravity section of code doesn't ever touch player.x/player.y.. How would I change the X/Y coordinates using Phaser's arcade physics? Or is there a better way of drawing the sprite? Thanks in advance
  5. Yeah that's all the code And I'm testing it on my laptop, Intel Core i7, 6GB ram, Intel HD 4000
  6. Hi, thanks for replying When I comment out removeAll() it starts to lag.. I'm guessing this is because of the amount of sprites on the screen at once. Did you mean to replace removeAll() with something else? If so, do you know what it is?
  7. Ok, so I've noticed my game draws 2 sprites.. One with no physics enabled in the foreground.. And the second with gravity working, but it's behind my game background. I've also noticed that when I implemented the gravity, it didn't use any X/Y coordinates, how do I make it change them? var game = new Phaser.Game(1024, 512 , Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render, update: update }); var player; var background1 = { x: 0, y: 0 }; var background2 = { x: 1024, y: 0 }; var playerX = 100; var playerY = 40; function preload() { game.load.image('playerImage', 'img/player.png'); game.load.image('backgroundImage', 'img/background.png'); } function create() { game.physics.startSystem(Phaser.Physics.ARCADE); // Set the world (global) gravity game.physics.arcade.gravity.y = 350; // Sprite 1 will use the World (global) gravity game.add.sprite(background1); game.add.sprite(background2); player = game.add.sprite(100, 96, 'playerImage'); // Enable physics on those sprites game.physics.enable(player, Phaser.Physics.ARCADE); player.body.collideWorldBounds = true; player.body.bounce.y = 0.1; player.body.gravity.y = 200; } function render() { game.world.removeAll(); game.add.sprite(background1.x, background1.y, 'backgroundImage'); game.add.sprite(background2.x, background2.y, 'backgroundImage'); game.add.sprite(playerX, playerY, 'playerImage'); } function jump() { } function moveRight() { } function moveLeft() { } function updateBackground() { background1.x--; background2.x--; if(background1.x <= -1024) { background1.x = 1024; } if(background2.x <= -1024) { background2.x = 1024; } } function update() { updateBackground(); }
  8. Ok, so I've noticed my game draws 2 sprites.. One with no physics enabled in the foreground.. And the second with gravity working, but it's behind my game background. I've also noticed that when I implemented the gravity, it didn't use any X/Y coordinates, how do I make it change them? var game = new Phaser.Game(1024, 512 , Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render, update: update });var player;var background1 = { x: 0, y: 0};var background2 = { x: 1024, y: 0};var playerX = 100;var playerY = 40;function preload(){ game.load.image('playerImage', 'img/player.png'); game.load.image('backgroundImage', 'img/background.png');}function create(){ game.physics.startSystem(Phaser.Physics.ARCADE); // Set the world (global) gravity game.physics.arcade.gravity.y = 350; // Sprite 1 will use the World (global) gravity game.add.sprite(background1); game.add.sprite(background2); player = game.add.sprite(100, 96, 'playerImage'); // Enable physics on those sprites game.physics.enable(player, Phaser.Physics.ARCADE); player.body.collideWorldBounds = true; player.body.bounce.y = 0.1; player.body.gravity.y = 200;}function render(){ game.world.removeAll(); game.add.sprite(background1.x, background1.y, 'backgroundImage'); game.add.sprite(background2.x, background2.y, 'backgroundImage'); game.add.sprite(playerX, playerY, 'playerImage');}function jump(){}function moveRight(){}function moveLeft(){}function updateBackground(){ background1.x--; background2.x--; if(background1.x <= -1024) { background1.x = 1024; } if(background2.x <= -1024) { background2.x = 1024; }}function update(){ updateBackground();}
  9. Hi, thanks for the reply! I have tried what you said, changing player to this.playerImage. It still doesn’t work though Also, thanks for pointing that out, I've changed it now
  10. I am making a game, everything works except the physics system? Collisions and Gravity are in the code but don’t seem to work. Using breakpoints, it gets to all the pieces of code but never actually works. I have tried to frantically make it work (Thats why theres so much physics code in the file). Can anyone please help me? This is the code that I think you will need: http://pastebin.com/0Sh8pqVJ This is all of the code together: http://pastebin.com/CfFuatdt Thanks.