Tourniquet Posted December 11, 2014 Share Posted December 11, 2014 Hi,as I said before I'm still very new to phaser and javascript. I read tutorials and wanted to test out some basic stuff. Unfortunately even there are some problems, but I'm not sure what I'm doing wrong. Atm you can only jump and I've choosen to collide my character with the platform. Sometimes if you start the game or jump, the character does not collide with the platform but I don't know why. Also i tested this on my phone and fps are very low ~11 is there any way to speed things up? [>click<]var y = 0;var j = 2; // 3 Lebenvar bird;var platforms;var cursors;var heads;var score = 0;var scoreText;var life = new Array();// Create our 'main' state that will contain the gamevar mainState = {create: function() { // Set the physics system game.physics.startSystem(Phaser.Physics.ARCADE); //game.physics.startSystem(Phaser.Physics.P2JS); background2 = game.add.tileSprite(0, 0, game.width, game.cache.getImage('background').height, 'background'); platforms = game.add.group(); platforms.enableBody = true; var ground = platforms.create(0, game.world.height - 52, 'ground'); ground.scale.setTo(4, 2); ground.body.immovable = true; this.bird = game.add.sprite(800, game.world.height - 250, 'bird'); game.physics.arcade.enable(this.bird); this.bird.body.bounce.y = 0.2; this.bird.body.gravity.y = 800; this.bird.body.collideWorldBounds = true; // Head heads = game.add.group(); for (var j = 0; j < 3; j++) { life[j] = heads.create(10 + j * 50, 10, 'head'); } j = 2; // The score scoreText = game.add.text(1300, 20, '0', { fontSize: '52px', fill: '#fff' }); // Call the 'jump' function when the spacekey is hit var spaceKey = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); spaceKey.onDown.add(this.jump, this); // Call the 'jump' function with touch game.input.onDown.add(this.jump, this); game.world.bringToTop(this.bird);},update: function() { // Collide the bird with the platforms game.physics.arcade.collide(this.bird, platforms)// Debug game.debug.text(game.time.fps || '--', 2, 100, "#00ff00");},jump: function() { if (this.bird.body.touching.down) { this.bird.body.velocity.y = -750; }},restartGame: function() { this.game.state.start('menu');},}; Link to comment Share on other sites More sharing options...
Tourniquet Posted December 12, 2014 Author Share Posted December 12, 2014 No one got an idea? I've tried both game.physics.startSystem(Phaser.Physics.ARCADE);game.physics.startSystem(Phaser.Physics.P2JS); But it's still the same, sometimes it works, sometimes it doesn't. =/ My main problem is that it's really slow on mobile phones. Link to comment Share on other sites More sharing options...
Recommended Posts