The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.39 / 5.00 38,635 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 15,161 ViewsI have the gun rotating towards the mouse I just need the bullets to rotate around the barrel of the gun. If you dont understand what Im asking here is what I have so far. http://www.newgrounds.com/dump/item/f28c 7b9919b2768402a3092cccb5d41c
the bullets' origin co-ordinates need to be at the bulk of the gun instead of the dog's center
I tried that but it dosent rotate around the barrel of the gun I put down
function playerShooting()
{
if (_root.dog.time > 6 && _root.dog.ammo > 0)
{
var bullet = _root.attachMovie("Bullet", "Bullet" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
bullet._x = this.xOrgin + 100 ;
bullet._y = this.yOrgin;
bullet.xSpeed = Math.cos(radians) * bulletSpeed;
bullet.ySpeed = Math.sin(radians) * bulletSpeed;
bullet.bulletSpeed = 30;
bullet._rotation = degrees;
trace(bullet._x);
trace(bullet._y);
_root.dog.ammo -= 1;
_root.dog.time = 0;
_root.dog.updateAmmo();
} Easy solution:
On the movieclip of the gun add a small block where you want the bullets to spawn from. Call this bulletblock, or whatever you want. Now just turn the opacity of it down ( or put it under your gun, just hide it OK? ) and add the bullets at the x and y positions of the block. Be sure to add the global position to it ( that of the gun, or the dog or both dunno how you've set it up ) or use the localtoglobal to acquire the correct point ( google that shit up ).
Good luck :3
"Insert deep, brain twisting sentence here"
Ive tried multiple ways and looked at examples I just done know how to get globalToLocal to work. Here is the code im working with.
class FrontOfArms extends MovieClip
{
var D;
var Dx;
var Dy;
var xOrgin;
var yOrgin;
var radians;
var line;
var degrees;
var bulletSpeed;
function onLoad()
{
bulletSpeed = 30;
}
function onEnterFrame()
{
this._x += _root.dog.walkSpeed;
if (this._xscale == 100 && _root._xmouse > this._x || this._xscale == -100 && _root._xmouse > this._x)
{
this._xscale = 100;
this._yscale = 100;
this._x = _root.dog._x - 10;
}
if (this._xscale == 100 && _root._xmouse < this._x || this._xscale == -100 && _root._xmouse > this._x)
{
this._yscale = -100;
this._x = _root.dog._x + 10;
}
xOrgin = this._x ;
yOrgin = this._y + 40;
Dx = _root._xmouse - xOrgin;
Dy = _root._ymouse - yOrgin;
radians = Math.atan2(Dy, Dx);
degrees = (360 * radians)/ ( 2 * Math.PI);
this._rotation = degrees;
}
function playerShooting()
{
if (_root.dog.time > 6 && _root.dog.ammo > 0)
{
var bullet = _root.attachMovie("Bullet", "Bullet" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
bullet._x = _x;
bullet._y = _y;
bullet.xSpeed = Math.cos(radians) * bulletSpeed;
bullet.ySpeed = Math.sin(radians) * bulletSpeed;
bullet.bulletSpeed = 30;
bullet._rotation = degrees;
trace(bullet._x);
trace(bullet._y);
_root.dog.ammo -= 1;
_root.dog.time = 0;
_root.dog.updateAmmo();
}
}}