Projectile Problems With Cloned Objects..
by Jack-S- · in iTorque 2D · 10/19/2011 (10:59 am) · 0 replies
Hi, Im having some trouble implementing a feature within my game, Ive been tackling it for a day now however with no success....
Basically I have my player shooting projectiles. In order to achieve this I have placed an object into the level called bigBomb. In order to get my player to shoot "bigBomb" I have firstly used this code,
%projectileSpeed = 200.0;
%projectile = bigBomb.cloneWithBehaviors();
%projectile.setPosition(playerShip.position);
%projectile.setRotation(playerShip.rotation);
%projectile.setLinearVelocityPolar(playerShip.rotation, %projectileSpeed);
This code works perfectly to shoot bigBombs, however the problem comes with what I wish to do once the player has shot the bigBomb. Basically I want to allow the player to remotely detonate this bigBomb projectile.
Once the player after shooting the bigBomb presses the fire button again I want the bigBomb.cloneWithBehaviors(); projectile to be swapped with another object which is cloned using the same strategy as I did above for bigBomb.
the problem is that it does work, however NOT! for the cloned bigBombs shot from the player.....
In fact the original bigBomb I placed in the scene to clone the projectiles from is swapped with the object and safelydeleted but not the clones shot from player!(and once its swapped the player can no longer shoot bigBombs)
How would I get the cloned bigBomb projectiles to be swapped with another object in their respective position and rotation while sill keeping my original non cloned big bomb intact??
If anyone could help me that would be great!
Thanks in advance.
Basically I have my player shooting projectiles. In order to achieve this I have placed an object into the level called bigBomb. In order to get my player to shoot "bigBomb" I have firstly used this code,
%projectileSpeed = 200.0;
%projectile = bigBomb.cloneWithBehaviors();
%projectile.setPosition(playerShip.position);
%projectile.setRotation(playerShip.rotation);
%projectile.setLinearVelocityPolar(playerShip.rotation, %projectileSpeed);
This code works perfectly to shoot bigBombs, however the problem comes with what I wish to do once the player has shot the bigBomb. Basically I want to allow the player to remotely detonate this bigBomb projectile.
Once the player after shooting the bigBomb presses the fire button again I want the bigBomb.cloneWithBehaviors(); projectile to be swapped with another object which is cloned using the same strategy as I did above for bigBomb.
the problem is that it does work, however NOT! for the cloned bigBombs shot from the player.....
In fact the original bigBomb I placed in the scene to clone the projectiles from is swapped with the object and safelydeleted but not the clones shot from player!(and once its swapped the player can no longer shoot bigBombs)
How would I get the cloned bigBomb projectiles to be swapped with another object in their respective position and rotation while sill keeping my original non cloned big bomb intact??
If anyone could help me that would be great!
Thanks in advance.
About the author