Jump to content

Search the Community

Showing results for tags 'weapon'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

  1. Hi, I'm new with Phaser, I'm wondering how can I create a group of enemies that appears at the side of the screen in a random Y position between 550px and 745 px, after they appear they need to start to fire to my character Right now I have a function to create the bullets and how they will be fired: createBullets:function(laserToFire,track,offsetX, offsetY, bulletDirection,fireRate,bulletSpeed){ weapon = gameSP.add.weapon(10, laserToFire); weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; weapon.bulletSpeed = bulletSpeed; weapon.fireRate = fireRate; weapon.trackSprite(track, offsetX, offsetY); weapon.fireAngle = bulletDirection;right } So what I'm looking to do is to have each one of my enemies within the group to fire to my character. Thanks in advance.
  2. I'm creating group of items (barrels). After killing some of items with weapon, I call items.callAll('revive');, but barrels are spawning in random position. Who came across with this problem? items = this.game.add.group(); items.enableBody = true; // inside for loop: var sprite = group.create(element.x, element.y, 'barrel');
  3. how can I define the hit area of a single bullet and a sprite
  4. Hello. I am using phaser weapon plugin and want fire in forEach loop: var weapon = game.add.weapon(10, 'bullet'); enemies.forEachAlive(function(enemy){ if(enemy.name == 'p1'){ player.rotation = game.physics.arcade.angleBetween(player, ednemy); weapon.fireAtSprite(enemy); } }); If I have 5 enemies in a row, and only 3 if them have name = p1, after executing this code, player sprite is rotate to the last enemy, but there is only one bullet. What can I do here?
  5. Hello. I am using weapon.fire() function and I want to set special property for bullet, that apear after calling this function. I tried to use forEach: weapon.bullets.forEach(function(bullet){ if(bullet.target == undefined){ bullet.taget = 'prop1'; return; } }); weapon.fire(); but this does not work.
  6. Just a quick little demo of something I thought would be fun to create. No smoothing groups or textures and dirty animations. PoC PoC PoC. All separate weapon parts are weighted to bones, so they can be positioned, scaled and rotated individually, to create endless weapons(Only 4 in this example), all from a single mesh. I've chosen to do it in 3Ds Max, although it can be done in code as well. http://playground.babylonjs.com/#ZIH5Y7
  7. I am making a platformer game which I have implemented a weapon fire method to shoot some projectiles. I find that I am unable to fire these projectiles along the X axis rather than the Y. Here is a that section of the code within the create function: weapon = this.game.add.weapon(1, 'bullet'); weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; and the code within create for the bullet: if(this.cursors.down.isDown){ weapon.bulletAngleOffset = 90; weapon.bulletSpeed = 300; weapon.x = this.fNobleRanger.x; weapon.y = this.fNobleRanger.y; weapon.fire(); } The projectile is firing from my desired sprite, however the projectile shoots up and then falls back down. I want to shoot the projectile along the X axis instead. Any tips? I am silly. Found out about fireAngle, but to further this question: is it possible to have this item not be affected by game physic gravity?
  8. Hello, so what I am trying do is quite simple I think I just don't know the best way to execute it. I want the camera to follow the bullet up until it dies/takes impact to the enemy or boundary then the camera is handed back to the player. I tried an if statement about the bullet being alive and else it would return to the player and that caused the bullet to be stuck on itself. I have additional code as well in the beginning to tell it to follow the player as well as this code in the beginning not too sure if this is causing an overlap or what. game.camera.follow(player(); //weapon systems laser = game.add.weapon(10, 'bullet'); laser.bulletKillType = Phaser.Weapon.KILL_CAMERA_BOUNDS; laser.bulletSpeed = 600; laser.fireRate = 250; // set bullet collision area to match its visual size laser.setBulletBodyOffset(24, 12, 6, 6); fireSound = game.add.audio('gun', 0.1); laser.onFire.add(function(bullet) { fireSound.play(); game.camera.follow(bullet); });
  9. In my platformer, the player has a number of different weapons (gun, energy blast, homing missile) and there may be a number of enemies (up to maybe 6) who will have one of the same weapons. From my understanding of the weapon plugin and tutorials, I should then be making a different weapon object for each of the players weapons and for each enemy. As I am wanting to attach a particle emitter to missiles I'm then going to extend the bullet class to make a missile. Question 1: I want autofire from enemies to fireAtSprite rather than just fire, I'm assuming the best way to do this is to extend the weapon class and overwrite the fire() method to call fireAtSprite() instead? Or is there a better way? Question 2: Where do I put the collision checks for the bullets? I can see a couple of options but would really like to know the performance implications as to which would be better. 1) Put an arcade collision call in the extended bullet update method to handle hitting scenery and hitting enemies - this seems neat in some ways as the code for the bullet hitting something sits with the bullet itself, however it feels like I'm going to end up with a lot of separate collision calls. 2) Put an arcade collision call in the state update along the lines of: this.enemies.forEach(function(enemy){ this.game.physics.arcade.collide(enemy.weapon.bullets, this.collisionLayer, this.shotCollisionLayer, null, this); this.game.physics.arcade.collide(enemy.weapon.bullets, this.player, this.shotPlayer, null, this); }, this); 3) In the custom bullet constructor, add all enemy bullets to an enemyBulletsArray and collide this in the state update method this.game.physics.arcade.collide(this.enemyBulletsArray, this.collisionLayer, this.shotCollisionLayer, null, this); this.game.physics.arcade.collide(this.enemyBulletsArray, this.player, this.shotPlayer, null, this); Many thanks, Gordon
  10. Hi, I am really confused why I am getting errors with this code from the weapon plugin: create: function() { //load current level this.loadLevel(); this.weapon = this.game.add.weapon(-1, 'explode'); this.weapon.fireFrom.setTo(300,300, 1, 1); this.weapon.bulletKillType = Phaser.Weapon.KILL_CAMERA_BOUNDS; this.weapon.bulletGravity.y = -1000; this.input.keyboard.addKey(Phaser.KeyCode.SPACEBAR) .onDown.add(this.weapon.fire, this); The error is: phaser.js:100951 Uncaught TypeError: Cannot read property 'width' of undefined at Object.Phaser.Weapon.fire (phaser.js:100951) It seems to be an issue with the context, but I have tried this.weapon, this.state, this.game all to no avail. Annoyingly if I run ZPlat.GameState.weapon.fire() from the console it shoots fine. If anyone can see what I'm doing wrong I'd be very grateful. Thanks, Gordon
  11. Hi, I'm currently in the process of making my first game having completed the zenva course and am confused by the weapon plugin. My game is a platformer shootemup type, where there will be the player and multiple enemies shooting a variety of ammo types. The zenva course covers making bulletpools and sharing them between enemy sprites, but does not mention the weapon plugin. On the face of it the weapon plugin looks great, sorting out a whole load of features neatly. However if each enemy has its own weapon tracking it, does that mean that it then gets its own bullet pool, all of which then need to be destroyed once the enemy is killed? This seems to somewhat defeat the point of the bullet pool. My question is then: can the bullet pools be shared between enemies OR should I just rely on the entire bulletpool being recycled along with the enemy itself as it is itself pooled OR should I just not bother with the weaponplugin at all? Any help or suggestions much appreciated, Thanks, Gordon
  12. Hi all, I've a problem with weapon.fire(), he return null. here, a part of my code (where i use weapon)
  13. hi, I would use a special effect with my prototype weapon. this special effect is : some particles when the weapon fire. concern the lines : this.animate_when_fire() game.time.events.loop( this.frequency,this.animate_when_fire,this ) When is use the function animate_when_fire with a loop, after a certain delay my game lag a lot. However i use only 3 particle each time of frequency (+/- 200ms). I use the same process for my other particles and i don't see any lag... what i'm doing wrong ? thanks for the assist _canon = function(delay,posx,posy,speed,frequency,variance,angular,_flag,kill_with_world){ this.delay=delay this.posx=posx this.posy=posy this.speed=speed this.frequency=frequency this.variance=variance this.angular=angular this.kill_with_world=kill_with_world this._flag=_flag this.flag_for_fire=true this._flag=true //canon Phaser.Sprite.call(this,game,this.posx,this.posy,'canon') this.angle=this.angular this.animate_when_fire() game.time.events.loop( this.frequency,this.animate_when_fire,this ) game.physics.arcade.enable(this); this.weapon=game.add.weapon(9,'bullet') if(this.kill_with_world){ this.weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; }else{ for (var i = 0; i < 9; i++) { this.weapon.bulletCollideWorldBounds=true this.weapon.bullets.children[i].body.bounce.setTo(1,1) } } // Because our bullet is drawn facing up, we need to offset its rotation: this.weapon.bulletAngleOffset = 0; // The speed at which the bullet is fired this.weapon.bulletSpeed = this.speed; // Speed-up the rate of fire, allowing them to shoot 1 bullet every 60ms this.weapon.fireRate = this.frequency ; // Add a variance to the bullet angle by +- this value this.weapon.bulletAngleVariance = this.variance; // Tell the Weapon to track the 'player' Sprite, offset by 14px horizontally, 0 vertically this.weapon.trackSprite(this,0,0,true); game.time.events.add( this.delay,function(){this._flag=false},this ) } _canon.prototype = Object.create(Phaser.Sprite.prototype) _canon.prototype.constructor = _canon _canon.prototype.update = function(){ if(this._flag==false && this.flag_for_fire){ this.weapon.fire() } } _canon.prototype.fire = function() { this.flag_for_fire=true this.weapon.fireRate = this.frequency ; this.weapon.bulletSpeed = this.speed; this.angle=this.angular this.weapon.bulletAngleVariance = this.variance; } _canon.prototype.animate_when_fire = function() { if(this.visible){ this.particlex = game.add.emitter(this.x+35,this.y) this.particlex.makeParticles("particle_canon") this.particlex.minParticleSpeed.setTo(100,-190) this.particlex.maxParticleSpeed.setTo(500,240) this.particlex.setAlpha(.4, .1) this.particlex.minParticleScale = .4 this.particlex.maxParticleScale = .7 this.particlex.minRotation = 0 this.particlex.maxRotation = 0 this.particlex.on=false this.particlex.start(true,200,null,3) } }
  14. Is there a way to get collisions to work with p2, or to go through the list of active bullets and get thier x and y location, Or what do I loose if I switch from p2 to arcade. Thanks
  15. Hello, I created weapon animated from a spritesheet however the images on the sheet where a bit oversized. I know I can make the spritesheet smaller but it kindoff defeats my purpose of learning more in programming;) So when I scaled the weapon itself (fireball) to be half its sprites size its starting position also changed. Therefore I figured I' d anchor the weapon in the right position. But for some reason it keeps stating " anchor = undefined". So, anyone sees whats going wrong here? //This line is the one bugging out. I tried setting the anchor on each bullet and on the weapon itself. The console states 'anchor is undefined" this.weapon.anchor.setTo(0.5, 0.5); var weapon; create: function () { game.world.setBounds(0, 0, 1920, 560); game.physics.startSystem(Phaser.Physics.ARCADE); game.physics.arcade.gravity.y = 1000; this.weapon = game.add.weapon(1, "fireball"); // here I scale the weapon the fireball this.weapon.bullets.scale.setTo(0.5); this.weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; this.weapon.bulletSpeed = 300; this.weapon.fireRate = 500; //will use more sprites in the near future this.weapon.addBulletAnimation('fire',[23], 10, true ); this.weapon.trackSprite(player, 0, 0 , false); this.weapon.allowGravity = false; this.weapon.bulletGravity.y = -1000; //here I attempt to set the anchor so the weapon will be pushed to the right startposition this.weapon.anchor.setTo(0.5, 0.5); //this.weapon = action.attack.weapon; console.log(this.weapon); //u create controls cursors = game.input.keyboard.createCursorKeys(); //register hotkey this.fire = game.input.keyboard.addKey(Phaser.Keyboard.W); // Stop the following keys from propagating up to the browser game.input.keyboard.addKeyCapture([Phaser.Keyboard.E]); },
  16. Hi, In the documentation of the Weapon, the property bulletClass speak the follow: bulletClass : Object => "The Class of the bullets that are launched by this Weapon. Defaults Phaser.Bullet, but can be overridden before calling createBullets and set to your own class type." that could be written: class MyWeapon extens Phaser.Weapon { contructor(){ super(); this.bulletClass = MyBulletClass; /*error here*/ this.createBullets(30, imgSprite); } } the problem is that que the method bulletClass executes internally the code: https://github.com/photonstorm/phaser/blob/v2.6.2/src/plugins/weapon/WeaponPlugin.js#L1130 this.bullets.classType = this._bulletClass; But this.bullets still not was instantiate(null), so throws the error "can not read property 'classType' of undefined". If i comments the line, everything works. Would this line really necessary? I'm using Phaser 2.6.2.
  17. Hi, I'm writing a class that extends Phaser.Weapon and i want that the method update() keep running, like this: class MissileWeapon extends Phaser.Weapon { constructor(game: Phaser.Game){ super(game, game.plugins); } update(){ /*this not execute*/ } } But it not running. If i add this "hack": class MissileWeapon extends Phaser.Weapon { constructor(game: Phaser.Game){ super(game, game.plugins); /*the hack*/ this.active = true; /*active plugin*/ this.hasUpdate = true; var test = game.plugins.add(Phaser.Weapon); /*Only for the game.plugins(PluginManager) start running*/ game.plugins.plugins.push(this); /*add my weapon in the PluginManager*/ } update(){ /*executing */ } } It seems that when extends of plugin Weapon, it not is added direct in the game.plugins (PluginManager), then the method update not executes. How could i make this without uses the "hack"? and i'm using Phaser version 2.6.2 thanks :-)
  18. Hi there, I want to extend Phaser.Weapon so I can create my own custom weapons. I know that you extend groups by using Weapon.SingleBullet = function (game) { Phaser.Group.call(this, game, game.world, 'Single Bullet', false, true, Phaser.Physics.ARCADE); return this; }; Weapon.SingleBullet.prototype = Object.create(Phaser.Group.prototype); Weapon.SingleBullet.prototype.constructor = Weapon.SingleBullet; But what about the weapons group? Are there any examples out there for this? EDIT: I used Weapon.SingleBullet.prototype = Object.create(Phaser.Weapon.prototype); and it seems to work. However, when I try to fire my bullet I get the following error Cannot read property 'getFirstExists' of null at Pistol.Phaser.Weapon.fire (phaser.js:101053)
  19. Hi there, I want to build a shotgun weapon for my game. This shotgun would shoot 3 (or more) bullets in a conical angle. However, from what I see, Phaser.Weapon only fires one bullet at a time. What do I do in order to get the weapon to fire 3 bullets consecutively
  20. hi, i'm searching to make a prototype with the weapon class but that don't work. i have this error : phaser.min.js:6 Uncaught TypeError: a.parent.removeChild is not a function at c.World.b.DisplayObjectContainer.addChildAt (phaser.min.js:6) at c.World.b.DisplayObjectContainer.addChild (phaser.min.js:6) at c.World.c.Group.add (phaser.min.js:11) at c.GameObjectFactory.existing (phaser.min.js:14) at Object.create (main.js:322) at c.StateManager.loadComplete (phaser.min.js:10) at c.StateManager.preUpdate (phaser.min.js:10) at c.Game.updateLogic (phaser.min.js:12) at c.Game.update (phaser.min.js:12) at c.RequestAnimationFrame.updateRAF (phaser.min.js:18) however i take this from these example https://phaser.io/examples/v2/weapon/asteroids what 's wrong ? Thanks. weapon = function(){ Phaser.Weapon.call(this,game,20,'rect') this.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; // Because our bullet is drawn facing up, we need to offset its rotation: this.bulletAngleOffset = 90; // The speed at which the bullet is fired this.bulletSpeed = 400; // Speed-up the rate of fire, allowing them to shoot 1 bullet every 60ms this.fireRate = 60; // Add a variance to the bullet angle by +- this value this.bulletAngleVariance = 10; this.canon = game.add.sprite(320, 500, 'rect'); game.physics.arcade.enable(this.canon); // Tell the Weapon to track the 'player' Sprite, offset by 14px horizontally, 0 vertically this.trackSprite(this.canon, 14, 0); } weapon.prototype = Object.create(Phaser.Weapon.prototype) weapon.prototype.constructor = weapon weapon.prototype.update = function() { this.fire() } var game_state = { create: function(){ game.physics.startSystem(Phaser.Physics.ARCADE) this.canon=new weapon() game.add.existing(this.canon) }, }
  21. Currently, in my game. I've done the following if (player.fireButton.isDown) { //firing straight up player.weapon.fireAngle = Phaser.ANGLE_UP; player.weapon.fire(); this.shootSfx.play(); } The issue with this is that when I hold down the `fireButton` the first millisecond of the sound is played on a loop. Basically, the sound just keeps resetting. How do I set it up so that it has to play the full sound clip before starting again? Also, are there any Phaser examples of sounds and weapons being used together?
  22. Hi there, I'm creating a simple platform game where you can shoot enemies. I've applied game.physics.arcade.gravity.y = 1000; But this seems to now affect my weapon class and bullets too! How do I set my weapons or bullets to NOT be affected by gravity? Here's the code I've used for reference: var playState = { //code to make assets goes here create: function(){ /*-- creating player --*/ game.add.sprite(0, 0, 'background'); game.physics.arcade.gravity.y = 1000; //Do not enable, need to fix gravity. this.player = game.add.sprite(game.width/2, 780, 'player'); this.player.anchor.setTo(0.5, 0.5); game.physics.arcade.enable(this.player); this.player.body.gravity.y = 1500; this.player.body.bounce.set(0.3); this.player.body.collideWorldBounds = true; this.player.cursor = game.input.keyboard.createCursorKeys(); this.player.fireButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); this.player.hp = 100; this.player.weapon = game.add.weapon(30, 'bullet'); // this.player.weapon.enableBody = true; this.player.weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; this.player.weapon.bullets.setAll('body.gravity.y', 0); this.player.weapon.bulletSpeed = 850; this.player.weapon.fireRate = 200; this.player.weapon.trackSprite(this.player);
  23. Hello, I'm trying to make separate weapon classes in an Asteroids-type game, for example a Missile.ts, Laser.ts, etc. What I have so far is this (Missile.ts): module Spaceroni { export class Missile extends Phaser.Weapon { constructor(game: Phaser.Game) { super(game, game.plugins); this.bulletKillType = Phaser.Weapon.KILL_LIFESPAN; this.bulletSpeed = 1500; this.fireRate = 20; } } } In my Player.ts I have weapon: Spaceroni.Missile; up top and I'm adding a weapon in its constructor with this.weapon = game.add.weapon(30, 'missile'); This isn't working (bulletSpeed and fireRate aren't changing), I think because game.add.weapon() creates a new weapon instance, separate from my Missile class. I would like to avoid putting all of this Missile-specific code directly into the Player class since I want to be able to change the weapon based on power-ups, as well as add the Missile weapon to enemies. Any ideas on how to properly extend the weapon plugin? Thanks in advance!
  24. Hello, I am new to Phaser and I am trying to make the bullet bounce in the y axis in Phaser. Does anyone know how to do it? Thank you.
  25. var player; var keys; var shootButton; var bullet; function create() { //game.add.sprite(0,0, 'background'); game.physics.startSystem(Phaser.Physics.ARCADE); //creates player player = game.add.sprite(0.45*600,600-50,'galaga'); game.physics.arcade.enable(player); // allows player to fire 2 bullets bullet = game.add.weapon(2,'bullet'); // when bullet leaves the screen, it will be destroyed bullet.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; // offset rotation bullet.bulletAngleOffset = 90; // prevents ship from auto firing bullet.autofire = false; // The speed at which the bullet is fired bullet.bulletSpeed = 400; //keeps track of how many bullets were shot bullet.shots = 0; // Tell the bullet to track the 'player' Sprite, offset by 16px horizontally, 0 vertically bullet.trackSprite(player, 16, 0); //enabling keyboard use keys = game.input.keyboard.createCursorKeys(); shootButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); } function update() { // Reset the players velocity (movement) player.body.velocity.x = 0; if (keys.left.isDown) { // Move to the left player.body.velocity.x = -150; } else if (keys.right.isDown) { // Move to the right player.body.velocity.x = 150; } else { //ship is idle } //shooting the bullet if (shootButton.isDown) { bullet.fire(); } } What I'm trying to do is prevent my player variable from autofiring(holding down space button to fire bullets.). I want the player to be able to shoot two bullets at a time, but only when the player presses the fire button rather than holding it. I was under the impression that bullet.autofire = false; would do the trick, but I was wrong. Am I using the autofire variable the wrong way?
×
×
  • Create New...