habibieamrullah

Members
  • Content Count

    8
  • Joined

  • Last visited

About habibieamrullah

  • Rank
    Newbie

Contact Methods

  • Website URL
    http://zofiakreasi.com/

Profile Information

  • Gender
    Male
  • Location
    Indonesia
  • Interests
    Game Development

Recent Profile Visitors

524 profile views
  1. I'm trying to use cocoon.io instead. Feel dizzy configuring Cordova. Always getting error on Android Studio when I try to build.
  2. Really like this tutorial. But why this time I get error page: 504 Gateway Time-out nginx
  3. I'm developing Phaser games for Android devices. I do not use Cordova Phonegap, please do not suggest me to do it. All I do is manually putting my HTML5 and JS files into an assets folder and calling it from Android WebView. Now, the problem is resolution. I always getting jagged images and not satisfied. Before using Phaser, I developed my HTML5 games by setting game's canvas width & height twice larger from device's screen. Then, I simply put css code to downscale the canvas to fit the screen. The result was good, images are crisp. But with Phaser, I can not set canvas width&height just like before. What is the solution?
  4. And the main issue is in this fire() function: function fire(){ var bullet = bullets.getFirstDead(); bullet.reset(playerShip.x, playerShip.y); var shootTarget = game.physics.arcade.velocityFromRotation(playerShip.rotation, 60); game.physics.arcade.moveToXY(bullet, shootTarget.x, shootTarget.y); }
  5. Thank you guys for your helps. It's really helpful and make me learn more. But, I'm sorry I'm still confused how to implement it. I've tried velocityFromRotation() but the result is, bullets fired toward 0,0 coordinate. What did I miss in this code below? var game = new Phaser.Game(gameWidth, gameHeight, Phaser.AUTO, "SpaceBandits", { preload : preload, create : create, update : update }); var firingAllowed = true; function preload() { game.load.image('playership', 'assets/playership.png'); game.load.image('enemyship', 'assets/enemyship.png'); game.load.image('bullet', 'assets/bullet.png'); } var enemyCounts = 10; function create() { game.physics.startSystem(Phaser.Physics.P2JS); enemies = game.add.group(); var tempXPos = game.world.width/enemyCounts; for (var i = 1; i < enemyCounts; i++) { var enemy = enemies.create(tempXPos * i, 100, 'enemyship'); game.physics.p2.enable(enemy,false); } cursors = game.input.keyboard.createCursorKeys(); playerShip = game.add.sprite(game.world.width/2, game.world.height - 100, 'playership'); game.physics.p2.enable(playerShip); bullets = game.add.group(); bullets.enableBody = true; bullets.physicsBodyType = Phaser.Physics.ARCADE; bullets.createMultiple(50, "bullet"); bullets.setAll("checkWorldBounds", true); bullets.setAll("outOfBoundsKill", true); this.spaceKey = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); }; function update() { enemies.forEachAlive(moveenemies,this); if (cursors.up.isDown){ playerShip.body.thrust(100); } else if (cursors.down.isDown){ playerShip.body.reverse(100); } if (cursors.left.isDown) {playerShip.body.rotateLeft(100);} else if (cursors.right.isDown){playerShip.body.rotateRight(100);} else {playerShip.body.setZeroRotation();} if (this.spaceKey.isDown){ if(firingAllowed){ fire(); firingAllowed = false; setTimeout(function(){ firingAllowed = true }, 300) } } }; function moveenemies (enemy) { accelerateToObject(enemy,playerShip,20); } function accelerateToObject(obj1, obj2, speed) { if (typeof speed === 'undefined') { speed = 20; } var angle = Math.atan2(obj2.y - obj1.y, obj2.x - obj1.x); obj1.body.rotation = angle + game.math.degToRad(90); obj1.body.force.x = Math.cos(angle) * speed; obj1.body.force.y = Math.sin(angle) * speed; } function fire(){ var bullet = bullets.getFirstDead(); bullet.reset(playerShip.x, playerShip.y); var shootTarget = game.physics.arcade.velocityFromRotation(playerShip.rotation, 60); game.physics.arcade.moveToXY(bullet, shootTarget.x, shootTarget.y); } This codes is modified from one of official Phaser examples.
  6. I know how to get current rotation of the player sprite, by using player.angle and then I'll get the rotation angle. But what to do then? How to convert that rotation degree into an X&Y coordinates based on it?
  7. Hi guys, I've searched but I didn't find any answer. May be I didn't know exact search keyword to navigate me to the answer. My question is, if I have a player sprite that dynamically change its direction (always in rotating left & right) then I want it to shoot toward its direction (not toward mouse pointer or any object, but its direction, its front), what should I do? I've tried to use game.physics.arcade.moveToXY but I don't know how to calculate the x & y for it. Thank you.