Bari Sax Posted March 3, 2016 Share Posted March 3, 2016 Hi all, still a new developer and learning the ropes. I'm currently building a bullet-hell esque game and I'm not sure if I'm generating enemies correctly. I get no console log errors, but none spawn on load. I'm using Phaser 2.4.6. Here's some code var enemyUfo; function create() { enemyUfo = game.add.group(); enemyUfo.enableBody = true; enemyUfo.physicsBodyType = Phaser.Physics.ARCADE; enemyUfo.createMultiple(7, 'ufo-enemy'); enemyUfo.setAll('anchor.x', 0.5); enemyUfo.setAll('anchor.y', 0.5); enemyUfo.setAll('scale.x', 0.5); enemyUfo.setAll('scale.y', 0.5); enemyUfo.setAll('angle', 180); enemyUfo.setAll('outOfBoundsKill', true); enemyUfo.setAll('checkWorldBounds', true); launchEnemyUfo(); } function launchEnemyUfo() { var MIN_ENEMY_SPACING = 300; var MAX_ENEMY_SPACING = 3000; var ENEMY_SPEED = 300; var enemy = enemyUfo.getFirstExists(false); if (enemy) { enemy.reset(game.rnd.integerInRange(0, game.width), -20); enemy.body.velocity.x = game.rnd.integerInRange(-300, 300); enemy.body.velocity.y = ENEMY_SPEED; enemy.body.drag.x = 100; } // MARS ATTACKS!! game.time.events.add(game.rnd.integerInRange(MIN_ENEMY_SPACING, MAX_ENEMY_SPACING), launchEnemyUfo); } Link to comment Share on other sites More sharing options...
Recommended Posts