Changing Angle Of Projectile
Hi,
I am trying to change the angle of the projectile depending on its roatation
ie ActionScript Code: if ( its rotation this){the angle of movement should be that
ActionScript Code: /////////////**** Here is the issue *********////////////the direction of the arrow ie angle , should be decided// by the rotation of the arrow when the mouse was pressed///dx = x_diff;dy = y_diff;//_root.direction = _root.arrow._rotation+90;//direction =Math.round((_root.rotationangle*180/Math.PI));direction = Math.atan2(dy, dx);speedX = Math.cos(direction)*power;speedY = Math.sin(direction)*power;arrow._x += speedX;arrow._y += speedY;trace(direction+" direction");}};
thanks
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 10-30-2008, 01:35 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Changing The Gun. Angle Detection Already Done.
Heeey
I'm trying to get a picture of a gun to addapt to the location of the mousepointer.
So the gun would always aim where the mousepointer would be.
I've done angle detection so i know the angle of the mousepointer in relation to the gun.
Simply rotating the picture only works in 2D. And my game looks 3d so can't do that.
Anybody any advice?
The game i'm working on is HL2 Total Mayhem
Play here: http://www.top-download.net/games/ha...tal-Mayhem.php
Cheers
Thierry
Pen Tool: Changing An Angle To A Curve
Quick question..
When editing a shape with the pen tool I was curious how one could turn a sharp corner angle into a curved one?
I tried various keyboard techniques to do this to pull out the bezier arms but couldn't seem to figure it out.
Any help is appreciated. Thanks! ~
d
Pen Tool: Changing An Angle To A Curve
Quick question..
When editing a shape with the pen tool I was curious how one could turn a sharp corner angle into a curved one?
I tried various keyboard techniques to do this to pull out the bezier arms but couldn't seem to figure it out.
Any help is appreciated. Thanks! ~
d
Changing Zoom Angle With Transition Manager
Hi guys and gals,
I'm making a map and would like to be able to zoom in and out of counties. I've got most of it down I believe, but would like to be able to control where the zoomed in image ends up. I'm using the transition manager information I found here.
Here is what my code looks like:
_root.img_dunn_mc._x = 82;
_root.img_dunn_mc._y = 235;
mx.transitions.TransitionManager.start(img_dunn_mc, {type:mx.transitions.Zoom, direction:0, duration:.5});
The x and y values are to make it appear that the county is zooming in from a specific spot on the map. When it zooms in, it simply makes the clip bigger. Is there a way to control the x and y coordinates of the zoomed in image?
Wow, I hope that made some sense.
Thanks!
Matt
[F8] Changing Angle Of A "line"
Hey, I am making a shooting game that a man is holding a gun and the gun's rotation points to the mouse. If you click the mouse, then a bullet movieclip is attached. I am wondering how to change the angle of the bullet, which is a thick line, so that it looks like the gun is shooting it out. I hope you understand this, if not ill try better. Just ask.
Projectile / Mortar / Arc
Hey all,
i did a search for this but really only came accross a wierd equation with symbols i dont understand.
How can you find out the path of soemthing in actionscript if you are given the angle and force. I have no idea where to start with this problem.
Thanks !!
For example a mortar, you fire it in the air vertically and the horizontal distance is calculated.
Projectile Script
Hi guys,
I have a very limited knowledge of physics and was hoping if someone knew of a public script out there that was a tutorial out there that covered projectiles, or if a script existed with the projectile parameters and easy to edit variables, like gravity, and gravity focus.
Thanks.
Projectile Direction
Hello. I am having a problem with firing projectiles in actionscript. What I need to do is have a gun that can be rotated using the arrows keys (I've gotten that far). I then need it to fire a projectile movie clip. The key here being that I need it to fire in the same direction that the gun is facing.
Any help would be appreciated.
Thank you.
Firing A Projectile HELP
I have made a turret which rotates using the mouse as a targeting reticle. I'm having trouble with clicking the mouse and a projectile firing from the turret and stopping where the mouse was clicked. Any help welcome.
Projectile Motion
Hi
I'm trying to script the movement of a projectile and am having fairly major problems. I know, from a physics point of view, where the object should be at what time, but im having trouble with things like timing the action. i.e. how long it's been in the air. etc. Does anyone have a similar script i can look at and see how it should be done? I do have one example but it is not documented at all so is pretty much impossible to follow.
Any help is greatly appreciated. Cheers
Stoot
Firing A Projectile On A Curve - Is This Possible?
Hi,
I'm developing a game in MX 2004 that currently involves a 'bullet' projectile being fired at key points.
Firing in a straight line is easy using the usual sprite firing code (on enterframe this._x -= 1; etc), but due to my game's interface design, I wondered if it was possible to make the projectiles follow a curve rather than just going straight?
I'm not entirely convinced that this is possible as I know that the projectile is currently just moved x amount of pixels each frame - any ideas? Could I use some maths / physics wizardry to sort this!?
Thanks in advance,
Skratch
[f8] Angles And Projectile Motion
Hello everyone!
I need to make a script where an object behaves like in the attached image, where I tried to illustrate that I need to set the direction/power of the jump with the mouse and an scalable Arrow MC.
I've seen it on so many places on the internet but I can't seem to find anything relevant on now... And google doesent helped me a lot on this
can please somebody point me in the right direction?
TNX a bunch guys!
Ovidiu
Easing Projectile Speed?
Hey guys, Im having a little trouble with this game Im making.
I have all the AS done for the players character, and the environment/enemys (dont have the animation yet...its all blocks and circles now) but I wanted the projectile that the player shoots to ease upward, because in the level im on the player is falling while shooting enemys...
You know what I mean? I know, Im not good with explaining things
oh, and Im also having a little trouble with changing an animation depending on where the player has his mouse...like if the cursor is on the right, the character faces right, ect ect.....but that isnt as important to the game.
If you guys could help me It would be greatly appreciated, and Ill post the finished product when im done.
thanks in advance!
Projectile Path Projection
This is just a little something that I was thinking about. It's a very small script, but may help someone who is wanting to achieve such an effect. Enjoy
ActionScript Code:
Stage.align = "TL"; Stage.scaleMode = "noScale"; _quality = "medium";var startX:Number = 0; var startY:Number = 0;var mouseIsDown:Boolean = false; var gravity:Number = 20;_root.onMouseDown = function() { startX = _xmouse; startY = _ymouse; mouseIsDown = true; }_root.onMouseUp = function() { mouseIsDown = false; }_root.onEnterFrame = function() { _root.clear(); if (!mouseIsDown) { return; } _root.lineStyle(1, 0xCCCCCC, 100); _root.moveTo(startX, startY); var hVel:Number = _xmouse-startX; var vVel:Number = _ymouse-startY; var t:Number = 0; var x:Number = startX; var y:Number = startY; var draw:Boolean = true; while (y < Stage.height) { t+=0.1; //how detailed the line is. 0 = infinitely detailed (don't use this, obv) x = startX + hVel*t; y = startY + vVel*t + 0.5*gravity*t*t; if (draw=!draw) { _root.lineTo(x, y); } else { _root.moveTo(x, y); } }}
Create A Tracer On A Projectile
I have a flash 8 movie that uses actionscript to create a projectile, kind of like a ball being fired from a canon. I want to create a line that follows and draws the path of the projectile. Any idea's???
Projectile Movement Between Two Points
Hey,
I have two points on the stage. I need to move a projectile from one point to the other with parabolic motion, reaching a certain maximum height. The known variables are, therefore, the (x,y) start coordinate, the (x,y) end coordinate, and the y coordinate of the vertex of the parabola. I've been trying for some time, but have been unable to find a flawless way to efficiently move the projectile between the two points. How would one go about doing this?
Thanks for your help!
Projectile Physics Question
I've created a very simple ballistics game, where a projectile can be thrown with varying force along a scrolling background - very much along the lines of a 'penguin throwing' game. So far so good... but at the moment the projectile moves with an initial x and y velocity, and what I would prefer is for the user to be able to input an angle and force of throw.
Could anyone enlighten me on how to calculate the x and y velocities, given an angle of throw from the horizontal and a force of throw?
Thanks in advance to any who's able to help
Make Projectile Come Out Of Ship?
Hello... I've seen a tutorial about this somewhere on the web, unfortunately it's for Flash 5 and it's not really written that well...
So can you please help me about how to make a projectile come out of a ship whenever I press a certain button (or even click the mouse)?
Thanks a lot!
Projectile Motion Line Drawing
The line drawing process should represent the projectile motion between starting point and end point. So a slight delay is required while drawing line pixel by pixel.
iam attached.swf file,in this file i did animation by masking.
I want this animation with Script.
please any body help me
[F8] Forward Momentum/Coordinates Of A Projectile
Hi, I have a projectile and I need to find the immediate coordinates directly in front of the direction that it is facing. Gravity does not apply to this projectile, and it can have any angle. So I gave it an angle of 22. I have tried (x,y)+(cos22, sin22) which, I was told by my math tutor, should give me the forward coordinates, but it did not. I have spent hours on this and cannot figure it out. Does anyone know how they can help? Thanks!
Projectile Motion Line Drawing
The line drawing process should represent the projectile motion between starting point and end point. So a slight delay is required while drawing line pixel by pixel.
iam attaching .swf file,in this file i did animation by masking.
I want this animation with Script.
please any body help me
Projectile Motion Easy Question
I know there's a problem here...I just can't see it. can anyone tell me why the ball keeps bouncing a little bit higher every time? In theory, it should bounce back to the exact same height.
fla is attached
any ideas? thanks
Problems With Rudimentary Projectile Motion
I have no idea what is wrong with this. Honestly. The _y of Bush goes above _root._height and still it does not stop animating. It starts out initially at a height that comes from god knows where. This was supposed to be easy
ActionScript Code:
var simulate:Boolean = false;var initialheight:Number;var currentheight:Number;var angle:Number;var initialvelocity:Number;var currentxvelocity:Number;var currentyvelocity:Number;var initialxvelocity:Number;var initialyvelocity:Number;var currenttime:Number;var currentframe:Number = 0;var framerate:Number = 30;var g:Number = 9.81;simulate_btn.onRelease = function() { if (velocityinput.text != 0) { initialvelocity = velocityinput.text; angle = stepper.value; initialheight = initialheightinput.text; initialheight = _root._height - initialheight; bush_mc._y = initialheight; currentxvelocity = Math.cos(angle) * initialvelocity; currentyvelocity = Math.sin(angle) * initialvelocity; initialxvelocity = Math.cos(angle) * initialvelocity; initialyvelocity = Math.sin(angle) * initialvelocity; simulate = true; }}onEnterFrame = function() { if (simulate == true) { currentframe++; currentvelocitytext = currentxvelocity / Math.cos(angle); currenttime = currentframe / framerate; if (bush_mc._y < _root._height) { bush_mc._y = _root._height - (initialheight + initialyvelocity*currenttime + (.5 * (-1 * g) * (currenttime * currenttime))); bush_mc._x = currenttime * currentxvelocity; } }}
FLA:
http://vexiron.com/physicsproject.fla
Help, Creating A Projectile Fired From A Weapon.
Hi, i have been working on a flash game for some time now. The game is based on that 2 characters are supposed to kill each other (no ****). They both start on each side of a wall with a random generated floor beneath them. The floor is made out of 3 different kind of cubes. One explosive, one destructible and one indestructible. every turn each player get 2 shots. Right now im stuck in the progress of the developing. I have created a random generated floor and one character that is able to jump and walk. He can also aim with his arm. Could anybody make my character able to shoot a projectile when the mouse button is clicked and then explain to me how it works? If you have enough skill to make the cubes destruct, explode or absorb the projectile that would be great. The variable that controls the arm rotation is "redplayer.redarm._rotation"
Thanks in advance for helping me out, the flash file is attached
Projectile Motion Line Drawing
The line drawing process should represent the projectile motion between starting point and end point. So a slight delay is required while drawing line pixel by pixel.
iam attaching .swf file,in this file i did animation by masking.
I want this animation with Script.
please any body help me
Help Tweaking And Understanding A Script (projectile Related)
Ok I'm currently trying to understand this script I found for a lil Projectile motion simulation.
I found this .FLA on a website, its from the book "Flash MX 2004 gaming demistifyed"
FLA -(http://safariexamples.informit.com/0...ile_motion.fla)
SWF -(http://safariexamples.informit.com/0...ile_motion.swf)
I'm trying to create something similar to this myself, however I'm having trouble understanding all the variables, and making some changes.
I've put some of the stuff that I dont understand in Bold
Code:
_root.onMouseMove = function() {
updateAfterEvent();
var mx = _xmouse;
var my = _ymouse;
angle = Math.atan2(my-cy, mx-cx);
cannon._rotation = angle*180/Math.PI;
};
_root.onMouseDown = function() {
var cosAngle = Math.cos(angle);
var sinAngle = Math.sin(angle);
var nosex = nose*cosAngle;
var nosey = nose*sinAngle;
var x = cx+nosex;
var y = cy+nosey;
var newDepth = ++depth;
var name = "ball"+newDepth;
var clip = _root.attachMovie("ball", name, newDepth);
clip._x = x;
clip._y = y;
clip.xmov = speed*cosAngle;
clip.ymov = speed*sinAngle;
clip.onEnterFrame = function() {
this.ymov += _root.gravity;
this._x += this.xmov;
this._y += this.ymov;
};
};
gravity = 1;
cx = cannon._x;
cy = cannon._y;
speed = 15;
depth = 0;
nose = cannon._width;
Can someone work out what "nose" is? I think it may be like for the end of the Cannon so that the ball comes out there? Also what are "cx" and "cy" and also "my", "mx" (at the beinging of code)
Earlier I tried to make a few changes, such as change the ball to an arrow. I did this by creating a new MovieClip which looked like an arrow and then changing "ball" to "arrow" which is what I called my MC. However when I test the animation nothing comes out of the cannon, I dont even see the arrow appear anywhere.
I then tried to change the actual ball and for some reason only its vertical size will change, even if I make it 3 times its original size horizontally nothing happens.
Thats about it now, if someone could help me with these problems then it would be a big help! Any and all advice is welcome.
Sorry its a lil long ^_^;
How Do I Create Weapon Inventory And Projectile Collision
i creating an rpg game and have all other factors in place and need to know how to create a weapon inventory- where as someone could click a button to change weapon at will-.
weapon 1 - MC - I-name : Bow
weapon 2 - MC - I-name : Sword
Getting An Angle
I have a helicopter and when you click with the mouse cursor, it adds another helipad, the helicopter starts at the first helipad and flies towards the next one in the array, so when you click, it adds another destination to the list. My problem, I want the helicopter to fly with it's tail to the back, getting the direction iut has to fly and then rotates it aacordingly, anybody that can help me???
it can be previewed at http://subman.deviantart.com
Check the helicopter chaos, this is the flash I'm having difficulty with..
Just click on the helicopter link, thanx for th einput in advance
Arc On An Angle
Hi,
Angles are drawn dynamically. They are measured and shown to users. I'm stuck on making arc for the angles drawn dynamically.
Any links, idea or help?
Angle
I have a two boxes center screen I did action on both as follows
onClipEvent (enterframe) {
_rotation-=2;
_x++;
_y++;
}
The first rotates up to far left corner 2nd bottom right corner.
onClipEvent (enterframe) {
_rotation-=2;
_x--;
_y--;
}
My quest is how would I get a 3rd + 4th box going opersite directions, Many thanks
Regards Barrie
Angle Between Two Mc's
hey
trying to calculate angel between two mc's
came up with this
ActionScript Code:
function angle(ob1, ob2) {
var o1 = eval(ob1);
var o2 = eval(ob2);
xDist = o1._x-o2._x;
yDist = o1._y-o2._y;
return (Math.atan(yDist/xDist)*180/Math.PI)-90;
}
but there seems to be something wrong with that
its only returning negative angels
any ideas whats wrong with it?
Angle
I have a two boxes center screen I did action on both as follows
onClipEvent (enterframe) {
_rotation-=2;
_x++;
_y++;
}
The first rotates up to far left corner 2nd bottom right corner.
onClipEvent (enterframe) {
_rotation-=2;
_x--;
_y--;
}
My quest is how would I get a 3rd + 4th box going opersite directions, Many thanks
Regards Barrie
Mouse Angle
Hi,
How do I track mouse's angle using trigonometry objects in
Flash 5? I need to find a way to convert any given x and y coordinates to degrees. (0 to 360)
Got any idea?
Thanks Much,
z27
Shooting At Any Angle
Hi,At the moment I have a movie clip that can move left right, up, and down, as well as rotate to any angle by keystroke. I was wondering though how
to write the code so it can shoot at any angle of rotation? At the moment the laser will follow the rotation of the movieclip, but will only go in the _x or
the _y coordinate, never both. Any ideas?
This is on the movieclip:
onClipEvent (keyDown) {
if (Key.getCode() == Key.RIGHT) {
_x = _x+2;
} else if (Key.getCode() == Key.LEFT) {
_x = _x-2;
} else if (Key.getCode() == 40) {
_y = _y+2;
} else if (Key.getCode() == 38) {
_y = _y-2;
} else if (Key.getCode() == 90) {
_rotation += -2;
_root.laser._rotation += -2;
} else if (Key.getCode() == 88) {
_rotation += 2;
_root.laser._rotation += 2;
} else if (Key.getCode() == 32) {
tank_x = getProperty("_root.tank", _x);
tank_y = getProperty("_root.tank", _y);
_root.laser.duplicateMovieClip("laser");
setProperty (_root.laser, _x, tank_x);
setProperty (_root.laser, _y, tank_y);
This is on the laser at the moment:
onClipEvent (load) {
laserMoveSpeed = 20;
this._x = _root.tank._x+60;
this._y = _root.tank._y;
}
onClipEvent (enterFrame) {
this._x += laserMoveSpeed;
if (this._x>600 or this._y<0) {
this.removeMovieClip();
Thanks,
Andy
Art-barn.com
Calculating An Angle
hi,
the math I was tought in highschool has left my brain along the years, so that's why now i have to ask this question here:
what is the correct syntax in actionscript for calculating the angle between two lines.
thanks in advance.
(The teachers told me I would need it some day, why didn't I believe them)
Checking Angle
i'm trying to figure out a way to to get the angle that the cursor is to a movie clip. if the movie clip was the center of a clock and the cursor was at 3 o'clock, it would be 90 degrees, 6 o'clock-180, and so on...
anybody have any ideas?
thanks
dougc
Angle Detection
this is a doddle, but I'm brain dead today.
all I want is some simple code to find the exact angle between the mouse and a movieclip. see I told you it was easy. nothing taxing here. Any ideas then?
cheers
Niall
Mouse Angle
I cant figure out. I need a simple mouse angle that says once the mouse is below 200(vertical) to tell target.
BTW thanks for all the help so far, this site is very cool.
Bubble MC From Different Angle
Please help. What am I missing?
I've decided to go different route with my bubbles. I have created a bubble via attachMovie method on level 4. Have called it "bubbleBottom".
Now I want to make it move and it's not going anywhere. I've tried a dozen different paths. Here is what I have latest:
function moveObject (mcName, number) {
name = eval(mcName);
speed = number;
moveSpeed = speed;
name._x += moveSpeed;
}
The call action on frame 1 is as follows:
moveObject("bubbleBottom",3);
When I debug, the variable level0.name=[movieclip:level0.bubbleBottom] shows in there and the moveSpeed=3.
Why am I having such a hard time passing the mc name when using attached movies on main timeline?
Please help.
Thanks MUCH in advance!
Gradient At An Angle?
I'm having trouble reproducing a gradient I made in illustrator. It is a linear gradient but it comes down at a 50degree angle. I can't seem to find any control that allows you to modify which direction a linear gradient is going in flash. Anybody have any tricks?
- Brian
the humble newbie
Determining An Angle.
I'm trying to find a tutorial or just the code if someone has it, showing how to determine the angle between two movie clips. For example, if I have two movie clips on my stage I want one of them to point towards the other. My trig is very rusty and I'm going crazy trying to find a good tutorial. Any help is appreciated.
Thank you.
The Mouse Angle
i would like to manipulate a frame inside a movie by a certian postion (x,y) on the stage. ive got stops on all frame,s inside the movie clip and i want to gotoandstop on certain ones depending on (lets say for this question )when the mouse rolls over an area between x400 and x500 can anyone help me? version 5 or mx
Help On Angle Formula
Im making a flash sorta 3d engine and I need a reliable angle formula (to get the angle with points X, Y, CX, CY)
Right now I'm using ACOS((X-CX)/Dis) where dis is the distance from X, Y to CX, CY. It seems that ACOS isnt all that reliable, and so I keep getting NaN. Does anyone know one thats fast and effective?
Angle From Coordinates
Hi,
whats a quick simple way of getting an angle (in radians) from an x,y coordinate?
thanks
phil.
Angle Move To X Y
i need to get a movieclip to move to a certain position when its roled over. i also need it to point to the position while its moving twards it. heres what i need.... onrollover change angle of mc and move to position. anybody got any ideas?
Height And Angle
how would i match the angle of a mc to the height of a mc like if its coming down then its facinf down and if its goin up hen its facing up, ect
Angle Input Box
How could i go about creating an input box which is rotated and slightly skewed. not perfectly horizontal
so when users type can type there name and it looks abit more funkier.
I hope you can do this, i tried putting in the input box into a movie clip and transforming it that way, but it didn't work.
Thanks for any help.
Dragging At An Angle
Hello again,
Need to drag an object fixed at a 45 degree angle. Any help would be appreciated. Thanks. Please also read my 'Obtaining Coordinates' post if you can help there too.
Mc Angle Detection
this script returns the angle of the mouse in a text box:
onClipEvent (mouseMove) {
x = this._xmouse;
y = this._ymouse*-1;
angle = Math.atan(y/x)/(Math.PI/180);
if (x<0) {
angle += 180;
}
if (x>=0 && y<0) {
angle += 360;
}
_root.angletext = angle;
updateAfterEvent();
}
Is there a similar script that will return the angle of a dynamically rotating mc that is constantly and randomly offset from the mouse angle, and post it in a text box.
|