Flash :: Changing The Direction Of A Ball On Collision Base On Speed

Jan 4, 2010

I am creating a ping pong game. And I want to create the ability to control the direction of the ball based on the impact on the paddle. If the ball is coming down at vy = 4; vx = 4;

and the paddle is moving to the left at vx = -5; I want the ball to slightly change its course depending on how fast the paddle is moving. It would probably reduce the balls vx speed on collision, therefore making the ball move more straight (close to the Y axis) when it is moving back up.

I figure the solution for probably doing this would be to measure how fast the paddle is going. My problem is the paddle is controlled by the mouse and has no certain speed. I am trying to figure out how I can measure the speed of my mouse traveling on the x axis.

I am probably going to create a timer that fires every few seconds to determine where the mouse was and where it is at. figure the difference and that will be the speed

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Flash Changing Direction When Ball Reaches Gutter In A Bowling Alley Type Of Game?

Aug 20, 2011

I am trying to make a bowling alley type of game. I want the ball to change angle when it reaches the gutter, but the problem I am facing is, how can I check when the ball has reached the gutter as the bounding box for a line/box in perspective is bigger and I want to check any point on the line when the ball is passing/crossing that point and moving so that I can change its angle and direction. And also does anybody have a collision method algorithm or physics to create the falling of PINS when the ball hits the PINS.

View 1 Replies

ActionScript 3.0 :: Ball Collision Inside Another Ball Using Gravity?

Jun 5, 2009

ball collision inside another ball using gravity.I have one large circle in the middle of the stage (its radius is 150 pixels). I have another circle inside of that one (20 pixels radius), this is the smaller ball that I would like to have bounce around inside of the larger one with gravity. When the small ball hits the edge of the larger circle, I would like it bounce inwards to the center of the larger circle. It keeps doing this until it eventually stops in the center of the larger circle at the bottom.

View 1 Replies

ActionScript 3.0 :: Direction Of The Ball In The Direction Of The Mouse

Mar 17, 2011

have a ball with the name of mc which can be moved using the keyboard .. when you press the left mouse button shoots the ball, this ball and the other flies in the face where the cursor was in the shot .. but if you move the cursor to another location and shoot a second time then the second ball is also flying in the direction of the cursor and the first ball change direction toward a second shot ..

ActionScript Code:
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.events.MouseEvent;

[Code]....

how to make that first ball did not change its direction and continued to fly in the direction of the shot?

View 5 Replies

ActionScript 3.0 :: Flash Speed Of Collision (physics)?

Jul 29, 2010

I have the values (x, y, xSpeed, ySpeed) of the movieclips (Hero and Badguy)Now, when they collide, how will i calculate how hard the collision is?Obviously weight, acceleration, etc. are out of the question, as it just needs to be based on their speeds.

View 4 Replies

ActionScript 3.0 :: Direction Of Ball Same As Of Cursor Mouse

Mar 17, 2011

I have a ball with the name of mc which can be moved using the keyboard .. when you press the left mouse button shoots the ball, this ball and the other flies in the face where the cursor was in the shot .. but if you move the cursor to another location and shoot a second time then the second ball is also flying in the direction of the cursor and the first ball change direction toward a second shot ..

ActionScript Code:
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.events.MouseEvent;
import flash.ui.Keyboard;
var dist:Number = 0;
[Code] .....
How to make that first ball did not change its direction and continued to fly in the direction of the shot?

View 1 Replies

ActionScript 2.0 :: Ball To Move In A Random Direction 0-360?

Sep 6, 2005

I would like the Ball to move in a random direction 0-360,Then i would like the Ball to richoche off of the BallBoundry in its reflected direction.

View 2 Replies

Professional :: Change Speed Of Symbol Without Changing Speed Of Entire Movie?

Aug 7, 2010

I want to add an animated .gif file to my movie.  So I created a new symbol and then imported the .gif file to the stage.  This created the symbol containing the animated .gif.I dragged the symbol onto the scene where I want it.  However, the animation seems to play at a different speed (fps) than normal.  So I changed the fps of the symbol (at bottom of Timeline where it says "fps").  But for some reason this changes the fps of the rest of the entire movie.

View 3 Replies

ActionScript 3.0 :: Changing Base Class Permanently In Flash

Dec 28, 2010

For some reason Adobe doesn't allow us to change the size of the handle in the default slider component. This handle is small and hard to click on quickly. If you try to increase the size of it graphically it just gets resized back down to 13x13 pixels. I've looked into the Slider.as code found in:

Program Files(x86)/Adobe/Adobe Flash CS4/Common/Configuration/Component Source/ActionScript3.0/User Interface/fl/controls/Slider.as

And found that on line 803 there is the code thumb.setSize(13,13). I tried changing that to 60,60 but it doesn't change the size of the handle. I don't know much about classes and I didn't think you had to compile these. I thought that in Flash when you clicked on the Components button that it loaded these classes in at that point but I must be wrong.

ActionScript Code:
override protected function configUI():void {
super.configUI();
thumb = new BaseButton();
thumb.setSize(60, 60);
[Code] .....

View 5 Replies

ActionScript 2.0 :: Speed And Direction With A MC?

May 15, 2005

I am having a problem with this actionscript, i post it on my mc but it doesnt work. (except for the turning it just wont go forward or back)

CODE:

onClipEvent (enterFrame) {
//This code will advance the car forward.
if (Key.isDown(Key.UP)) {
speed += 1;

[code]....

View 14 Replies

ActionScript 2.0 :: Simulate Collision Of Block And Bounce Like Ball

Oct 12, 2004

I make this simple system to simulate a collision of a block in "walls" and bounce like a pong ball. To use drag the orange square and release to start the movement. But I have a problem, sometimes the collision not happen and the block go through the walls, I try less the time of setInterval that verify the collisions but not solve my problem.
collision system -> [URL]

View 3 Replies

ActionScript 3.0 :: Verlet Collision Detection - Direction

May 31, 2011

Ok so I have been doing a bunch of flash games for a while now. And it has been fun doing them with some basic physics(euler). But there comes a time when you need to step out onto deep waters. So I decided I would try to learn how to make some sort of more advanced physics engine. So I could do awesome collisions and cool ragdolls! After some googeling I found the �verlet� method. So yesterday and today I have tried to learn how to do that. To implement the motion to a point is as easy as it was with euler. But the collision detection stuff is a bit harder(or is it??). With euler, If I have an object, like the player, and I want him to follow the ground, I would code something like this.

[Code]....

View 1 Replies

ActionScript 1/2 :: Stop Ball Depending Upon Speed?

May 24, 2010

I want to stop ball depending on the speed. when i will set the ball speed that time i want to move this ball on this speed.

[Code]...

View 1 Replies

ActionScript 2.0 :: Move Ball Depending Upon Speed

May 25, 2010

I want to stop ball depending on the speed. when i will set the ball speed that time i want to move this ball on this speed.

View 5 Replies

ActionScript 2.0 :: Record Ball Speed To Display In Statistics

Oct 20, 2004

I want to record the highest xspeed the ball reaches to display in the statistics at the end of the game:

-the ball movieclip is called ball
-the speed i want to record is called xspeed
-the text variable name is called statistics

View 6 Replies

ActionScript 2.0 :: Record Ball Speed To Display In Statistics?

Oct 20, 2004

I want to record the highest xspeed the ball reaches to display in the statistics at the end of the game:

the ball movieclip is called ball the speed i want to record is called xspeed the text variable name is called statistics

View 6 Replies

ActionScript 2.0 :: Controling A MC's Frame Rate, Speed And Direction?

Jun 1, 2008

I have a embedded video animation clip that I need to control the speed it plays.The animation is of a ball spinning and when its rolls long X access i need the animation to move at the speed of the mc moves and slow down at the same rate.dose anyone know if I can control the frame rate and speed of a mc and the direction which is plays?any other option is to rotate an png but the problem im having with that is: when i import a circle png and brake it apart then remove the extra parts of the image leaving just the circle and have it aligned to the center. when i rotate it and move it along the X access base of the height of the mc it bobs up and down like this still counting the removed parts of the png in the

View 2 Replies

ActionScript 3.0 :: Programmatic Animation - Ball Moves At A Certain Speed From The Left Of The Screen To The Right?

Feb 27, 2009

I've just learned the basics of programmatic animation in Actionscript 3.0 but I can't seem to think of the right solution for this problem.Here is what I'm trying to do: A ball moves at a certain speed from the left of the screen to the right end. If there's a box in the way, it keeps bumping into it until the box breaks and it continues moving forward.The box will have a set weight that will control how much it slides when it is bumped by the ball. The ball will be pushed back a bit when it bumps the box.I have a very specific idea and all I need is a little help starting. How would you tackle this problem?

View 4 Replies

ActionScript 2.0 :: Dynamically Changing Base Folder Of App At Runtime?

Nov 17, 2010

I have a flash file in folder "/" which loads another flash file in folder "/xyz/". The second flash file will load several resource files on its own. Now flash is looking for the resource files at the base folder "/" and instead of the other loaded flash's folder "/xyz/". The second loaded flash file is provided by a third party and can't be modified. Is there any way to dynamically change the base folder of the "application" at run-time? I've heard about the html swf tag "BASE" so I've tried loading the second flash file with a ".....?BASE=/xyz/" but it doesn't work.

View 0 Replies

ActionScript 2.0 :: Bit101-collision-agony - Make Them Collide, And Make The Ball Bounce Away?

Apr 13, 2003

I followed the bit101 tutorial on gravity and now have a movie clip called "ball" (instance name) with an embedded invisible button (so you can throw it all over the place).I also have a movie clip called "block1" (instance name too! what a coincidence, isn't life lovely). I want to make them collide, and make the ball bounce away.

View 1 Replies

ActionScript 3.0 :: Changing The Tweening Direction?

Sep 21, 2009

I have small popup box which expands from size zero to some size when clicked on the expand button.

The location of this expand button is dynamic.Hence I want to change the the direction in which this expansion happens depending on the position of the expand button.

For example if the expand button is at the bottom right corner of the stage i want the popup box to expand upwards and leftwards.

If the expand button is at the top left then i want the popup box to expand downwards and rightwards.

I have only one movieclip for the popup box with the registration point at the top left corner.

I tried to achieve this by dynamically changing the registration point of the popup box movieclip using the DynamicMovie class. But no luck.

If I manually change the registration point it is working.

View 2 Replies

ActionScript 3.0 :: Changing Direction Of A Movieclip Using Enter_Frame?

Jan 3, 2011

Would some wonderful person be willing to take a look at this code and tell me what I'm doing wrong?

I'm trying to use ENTER_FRAME method to get a moving movieclip to change direction when it hits certain x and y coordinates. I want the movieclip to move horizontally, then down, then horizontally again. With this code my movieclip starts off moving down at a diagonal and I can't for the life of me figure out why. (probably something simple I'm overlooking?) I'm a beginner at actionscript.

[Code]...

View 4 Replies

ActionScript 2.0 :: Changing Direction Of Thumbnail Strip?

Jun 27, 2006

I have been following through the "gallery" tutorials here on Kirupa, and finally got to the third version (the one with the auto-scrolling thumbnails along the bottom, which scroll left / right based on the mouse pointer position, and the keyboard Left / Right scrolling).

I need my thumbnails to scroll UP and DOWN instead of LEFT and RIGHT, and have been trying to modify the ActionScript that came with the downloadable .fla file for the tutorial, but without complete success yet. (The functionality of the whole thing is still intact except for the scrolling thumbnails.)

Here is the portion of the AS that addresses the thumbnail scroller, and I have highlighted in red the variables that I believe need to be swapped around for it to scroll vertically instead of horizontally. I have made the obvious changes such as :-

_width changed to _height
hit_left changed to hit_up
hit_right changed to hit_down
_x changed to _y

[Code].....

Again, this is the ORIGINAL ActionScript, not my modified version. Only the items highlighted in red have been changed in my modified version. Basically when I test the movie now, I get the last two thumbnails of the gallery transposed one over the other, at the point of the movie clip instance, and no scrolling at all. When I use the UP and DOWN keys, I do get to "manually" scroll through the big images, but no change in the thumbnail area.

What have I screwed up or overlooked? I have scanned and scanned and scanned the above section of the AS, and I can't see any other variables that ought to be meddled with.

View 4 Replies

ActionScript 2.0 :: Changing Image Direction In Easing?

May 13, 2008

I'm currently having problems finding anything thats helps me change the direction an image is facing depending on mouse moment. I've found stuff on rotation, but I want my image to flip so its facing the other way.

View 4 Replies

ActionScript 2.0 :: Calculate The Direction And Speed A Circle Has After Colliding With A Static (non-moving) Circle?

Mar 8, 2005

I'm developing a game atm, and I need some help on the mathematics/coding of colliding circles (and their change in x/y speed). What i need to know is how to calculate the direction and speed a circle has after colliding with a static (non-moving) circle. I know how to detect a collision between the two, but I'm not sure about the maths I need to give the circle the right speed and direction after the collision

If i do know how far away the two circle-points (in the middle of each) are to each other (in both x and y coords) would it be easy for me to find the new speed and direction of the large circle in the example above? I know that I somehow should use the angles to pretend the circle hits a flat "wall" (as it only hits one point), and then calculate the new speed/direction. My only problem is that I'm not sure how to decide the angle of this flat "wall" and how x and y speeds should change when colliding with a wall that is angled. Does anyone here have any insight, links or tips on how I can du this?

View 6 Replies

ActionScript 2.0 :: Calculate Direction And Speed Circle Has After Colliding With A Static Circle?

Mar 8, 2005

What i need to know is how to calculate the direction and speed a circle has after colliding with a static (non-moving) circle. I know how to detect a collision between the two, but I'm not sure about the maths I need to give the circle the right speed and direction after the collision.If i do know how far away the two circle-points (in the middle of each) are to each other (in both x and y coords) would it be easy for me to find the new speed and direction of the large circle in the example above? I know that I somehow should use the angles to pretend the circle hits a flat "wall" (as it only hits one point), and then calculate the new speed/direction. My only problem is that I'm not sure how to decide the angle of this flat "wall" and how x and y speeds should change when colliding with a wall that is angled.

View 6 Replies

ActionScript 3.0 :: Collision - Why Variable Not Changing

Jun 21, 2011

I'm working on code for collision. My question isn't about how to make it work. I have a bizarre problem with a variable that is NOT changing when I want it to.

ActionScript Code:
public function movement(e:KeyboardEvent){
var yesobject:Number = 0;
var thecode:Number = e.keyCode;
if(thecode == Keyboard.LEFT){
[Code] .....

I've had this problem before. the trace(); commands outputs so why does the variable not change even though it's in the same if statement?

View 1 Replies

Professional :: Changing The Speed Of MovieClip

Jan 1, 2011

I am new to Flash and Actionscript and am currently working on some code pulled from another post to try and learn from what others are doing or have done. I have created a star movieclip and am attempting to move it randomly accross the stage in a relatively slow speed. When I run it, it moves randomly but way too fast. I have spent the last 6 hours playing with the code, researching help files and also looking up other discussions but nothing seems to be helping. Here is what I have so far. My apologies if the code looks like a hack. This is being done in CS4 if that matters at all. If anyone could shed some more light on how to handle controlling the speed or rate of random movement with some insight

[CODE]....

View 3 Replies

Change Speed Without Changing The Frame Rate?

Apr 3, 2009

way to change the speed of my movieclip without changing the frame rate, as it will mess the rest of my animation up. It looks great at 12fps but the rest of my animation is 24fps. I seem to of come across quite a lot of things about gotoAndStop function but I don't know if this would work as the animation is constantly flowing so wouldn't it suddenly jump? I made one petal and applied the following code to it (kindly done by Gu35s) so there are lots of random pretals moving across the screen, it is done in a similar way to how snow is done using actionscript. Here's the code:

var p = 0;
this.onEnterFrame = function() {
mc = this.attachMovie('petal_mc', 'petal' + p, p);
mc._x = tree_mc._x + (Math.random() * tree_mc._width);

[Code].....

View 4 Replies

ActionScript 3.0 :: Changing Datagrid Scrolling Down Speed?

Jul 25, 2011

Just something curious, can I change the datagrid scrolling speed?

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved