ActionScript 1/2 :: Intersection Of Line Segments Vs. HitTest?

Nov 2, 2009

I'm trying to improve upon the hitTest() function.I have a game in development that involves square robots, rectangular wall shapes, and line segment shots rotating and moving around. Without the rotation, hitTest works fine, but with rotation, problems arise.Walls at rotation 0,and square robots work fine. There is a small amount of funkyness with a rotated robot by a wall corner, but it's not very noticable.The big issue is collision of two rotated square robots.
 
I can create a function to get the line segments that make up each robot, and the check to see if any intersect. This will mean finding the location of eight points (using height and width and some trig to deal with rotation), finding the slope of eight lines, and then testing lines for intersection up to 16 times. This would be needed to find the intersection of each pair of robots. Those are worst case numbers, some colisions can be detected or ruled out before getting that far in the algorithm, but this check would need to be run every frame against all robots and walls and shots (shots could be a single line segment, though)Right now I'm talking about 8 robots max, maybe 6-20 walls, maybe 5-80 shots on screen @ 30 frames a second.
 
This is easy enough to create, but before I spend a day coding it all, I'm wondering if the computation requirements are going to make it prohibitive.(If so, I'll probably have to switch to circular robots).I feel like there should be a simple formula to find if two rectangles on a cartesian plane intersect, but I can't find one.

View 3 Replies


Similar Posts:


ActionScript 3.0 :: THICK Line-line Intersection?

Aug 15, 2009

Finding the intersection point of 2 line segments is easy enough.

But now I need to test wether a line with thickness intersects another (non-thick) line.

My idea is to actually perform 2 tests, one at the top and bottom of the thickness of the line. Does that make sense? Is there a better way to do it? I dont need the intersection point, just a boolean yes or no.

View 7 Replies

ActionScript 3.0 :: Detect The Point Of Intersection Of A Line And A Triangle?

Nov 27, 2010

There is some information but I couldn't figure it out:How can I detect if a line intersects with a triangle ? And how can I detect the point of intersection in AS3 ?

View 1 Replies

Actionscript 3 :: Intersection Of Parabolic Curve And Line Segment?

Aug 31, 2010

I have an equation for a parabolic curve intersecting a specified point, in my case where the user clicked on a graph.

// this would typically be mouse coords on the graph
var _target:Point = new Point(100, 50);
public static function plot(x:Number, target:Point):Number{
return (x * x) / target.x * (target.y / target.x);

[code]......

View 4 Replies

Professional :: Anchor Points On Line Segments?

Feb 14, 2010

Closed path made with pen tool in Flash MX  comprises of line segments & curved segments both.While adding anchor points on segments it is noticed that pen tool adds anchor points on curvaceous segments but not on line segments. Why is it so ? Is their any way to accomlish this task ?

View 5 Replies

IDE :: HitTest The Line Drawn In ^ With A Clip Called Enemy?

Mar 3, 2010

im making a game where when you click a line is drawn in the direction you clicked. I need to use hitTest with it, how would i go about doin that? here is the stuff.This is on the main timeline, it links to the gun. "bullet" is an empty clip

Code:

gun.onEnterFrame = function ()
{
var angle:Number = Math.atan2 (_root._ymouse - this._y, _root._xmouse - this._x);[code]....

i Need to hitTest the line drawn in ^ with a clip called enemy. How would i go about doing that?

View 3 Replies

ActionScript 2.0 :: HitTest - Detect Collisions Between Movie Clips And A Line

Nov 26, 2004

How do I detect collisions between movie clips and a line created through actionscript (with the lineStyle, lineTo, etc. commands). I tried making the line inside a movie clip and doing a hitTest with that movie clip, but it did nto work.

View 1 Replies

ActionScript 2.0 :: Vector Intersection To Pseudo?

Jul 23, 2009

as possible because I'm having a competition of some sort of..... In Flash Action Script Language Form the code of Vector Intersection will be in this way:

Code:
v3={vx:v2.p0.x-v1.p0.x, vy:v2.p0.y-v1.p0.y};
var t=perP(v3, v2)/perP(v1, v2);

[code]....

View 4 Replies

Actionscript 3 :: Calculate Intersection Between Shapes In Flash?

Dec 24, 2010

I need to calculate the intersection between two shapes in flash / action script. The problem is I can't access the shape's nodes and segments, and their coordinates, so there's no way I can calculate this. Do you know a way?

edit: further explanation: I imported irregular polygons from an EPS file to a movieclip with shapes in it.The mathematical solution to the problem is trivial, but to do that, I need to access by AS code to the coordinates of the nodes that make up the polygons, which I tried with no success. That is what I'm trying to accomplish.

edit2: dismiss this question. It's not possible. The workaround I'm applying is to save the polygons in SVG and parse them to get a list of nodes. then will feed that list to flash to calculate the intersection and areas on runtime.

View 2 Replies

ActionScript 3.0 :: Intersection Of Two Vectors Using Perpendicular Product

Jun 11, 2011

I am currently working my way through a book on Game Programming in Actionscript 3, and have gotten to a formula required for collision detection on finding the intersection point of two vectors. Im not sure if the author uses vectors in the strictest definition, but the convention he uses is e.g for a vector V1 :

V1.a is the start point of the vector V1.b is the end point of the vector V1.ln is the vector perpendicular to V1 (its 'left normal') V1.vx is the difference between the x coordinate of V1.b and V1.a V1.vy similar to vx V1.dx is the same as vx , but for V1 scaled down to a unit vector (the direction vector) Now,in the example we have V1 which is the motion vector of the ship, and V2, which is the target vector (i.e the line the ship is going to collide with at some point)

In order to calculate at what point on V2 the ship will collide travelling along motion vector V1, the book gives the following code using the "perpendicular dot product" (Which i have not come across before) and creating a third vector V3 between the start point of V1 and the start point of V2 (V1.a and V2.a):

[Code]...

View 1 Replies

Flex :: LineSeries AreaSeries On AreaChart - Get The Intersection Point?

May 4, 2010

I am plotting an AreaSeries and a LineSeries on a AreaChart using Flex 3 in built chart components. I want to code a custom item renderer for LineSeries to be shown at the intersection points where LineSeries crosses AreaSeries.

View 1 Replies

Flash 9 :: Loading A SWF In Segments?

Oct 9, 2008

I have a site that is image heavy and right now I have it so everything loads at once with a preloader and once it is all loaded the the site starts. I know I can load images through XML but i never liked doing that since the images seem to load at different rates.

Is it possible to only have certain parts load? Say I want only the homepage content to load when a user hits the site. But if they go to another area then another preloader would show up and that would load.The one thought I had was to have different swfs for different segments, but I wonder how that would mess up the flow of the site.

View 0 Replies

ActionScript 2.0 :: Trace Segments In It?

Jan 24, 2009

What is the equivalent of the following program in AS 2.0?

In other words, how can I trace segments = a line between 2 points defined with their coordinates (x1,y1) and (x2,y2) ?[code]...

View 2 Replies

Regex :: Replacing Segments Of A String?

Jun 6, 2011

I have absolutely no knowledge in Regex whatsoever. Basically what I'm trying to do is have an error class that I can use to call errors (obviously) which looks like this:

package avian.framework.errors
{
public class AvError extends Object
{

[Code].....

The idea is to replace {0} with the first parameter parsed in ...params, {1} with the second, etc.

I've done a bit of research and I think I've worked out that I need to search using this pattern:

var pattern:RegExp = /{d}/;

View 3 Replies

ActionScript 3.0 :: Playing X Segments Of A Mc In Succession?

Sep 25, 2011

I have a movieclip that shows the waterlevel rising in a glass. Frame 0 is named "empty", frame 20 is named "1/3", frame 40 is named "2/3" and frame 60 (the last frame) is named "full". Each of these keyframes contains the actionscript stop();

I have a variable in my main timeline, that contains a number ranging from 1-4. Depending on that number I want the glass to fill. e.g. var howFull:uint = 3 ---> the movieclip should playback from frame 0 to frame 20 AND THEN to frame 40. I've tried using nested if statements to make the mc segments play in the right order:

[Code]...

View 3 Replies

ActionScript 2.0 :: Preloader That Loads MC In Segments?

Oct 17, 2005

I have a MC named "preloader". Inside this MC got 10 frames and each of it represents a pencil. Frame 1 had 1 pencil, frame 2 had 2 pencils... and so on until frame 10(10 pencils ofcoz)After that I adding 3 frames on my root. Frame 1 is Actionscript as follow:

Code:
totalBytes = Math.round(getBytesTotal()/1024);
loadedBytes = Math.round(getBytesLoaded()/1024);

[code]......

View 4 Replies

Professional :: Minimum Amount Of Segments With Pen Tool?

Oct 28, 2011

I have a really basic question using the pen tool in Flash. Is there a minimum amount of segments (or something that I'm not doing) that need to be drawn in order to close a polygon shape created with the pen tool. I've found in many instances I seem to be closing the polygon and yet when I go to fill the object it won't fill. I then discover that the beginning and end points are not "joined" together (as in Illustrator).

View 4 Replies

Media Server :: Extract HDS Fragments And Segments From A .f4f?

Mar 13, 2012

I'd like to be able to manually extract the HDS fragments and segments from a .f4f file.  I have the .f4m and .f4x as well.  Once extracted, I'd like to be able to host the fragments and segments on a standard origin (web) server such as Amazon S3.  Is there any way to do this?  If not, does Adobe have any plans on releasing such a tool?

View 1 Replies

Flex :: Draw Segments Linechart In Different Color

Mar 19, 2010

I'm doing some line charts in my Flex application, and I need to draw segments of those line chart in different color. Does anyone have an idea how this could be achieved? For instance, if I have a code like this (actually, I have given this trivial example for simplicity (the problem is the same)):

[Code]...

View 1 Replies

ActionScript 3.0 :: Splitting A Mp3 (Sound) Into Small Segments?

Jan 13, 2009

I am looking for a way to split a loaded mp3 Sound into small segments. I have googled around but cannot find anyth on the matter. I am begining to think it is impossible. My approach was to load the mp3, then use the extract function to extract all the bytes. now for every small section when the user wants to play it it is filled using SampleDataevent with some values from the array. At first i tried to do my idea by loading an mp3 into a bytes array then writing it to a new file and playing that file but it does not work:

Code:
var snd:Sound = new Sound();
snd.addEventListener("complete",loaded);
snd.load(new URLRequest("Burn.mp3"));

[Code]....

View 0 Replies

ActionScript 2.0 :: Flash Mx Loading Large Mp3 In Segments?

Oct 23, 2009

I have an Mp3 which is approx 100mb on my server how can i load only small segments at a time so that when people listen to the mp3 it not downloading the full 100mb mp3 file all the time

i am using streaming mode, here some of my code i am using the loadsound command

[Code]...

View 0 Replies

ActionScript 2.0 :: Frameset - Flash Segments: How To Send Values

Dec 20, 2005

I am in the planning stage of an application. In fact, the application already exists but I am thinking about how to improve it. It's a sports event commentary viewer- it allows the user to view live commentary on soccer games, written by news scouters during the process of the game. Right now, it's all one big file, reading 7 different XML files on the fly, evaluating and processing them and displaying the data on screen.

It works well enough like this but now the whole thing is supposed to be expanded with live news feeds and a videoclip gallery, etc... and even though it would be possible to just keep expanding the file, I thought it would be cool to instead make several segments and put them in an HTML frameset. Now the question is: Is it even possible to pass values from one flash file that is running in one frame- to another one, running in another frame? Of course I will know the framename- so could use getURL with the framename as a target... but that would fully reload that frame and "cold-restart" the swf in that frame- I don't want that.

[Code]...

View 10 Replies

ActionScript 3.0 :: Poor Scaling When Drawing Some Long Lines Segments

Nov 19, 2009

I ran into a problem when attempting to draw long line segments - some lines will be poorly scaled and appear very thick. I ran into this issue when building a Google Maps Flex application and thought the problem resided there, but I then tested with a basic Flex application and duplicated the problem.

Here it is:
Code:
var _lineSprite:Sprite = new Sprite();
Application.application.rawChildren.addChild(_lineSprite);
_lineSprite.graphics.lineStyle(
6, // thickness
0xFF0000, //color
1.0, //opacity
true, //pixel hinting
LineScaleMode.NONE);
_lineSprite.graphics.moveTo(-70000,-20000);
_lineSprite.graphics.lineTo(400, 400);

The code above will draw a line segment that is much thicker than the desired 6 pixels. The problem can be seen here: [URL]. Once the page loads, click the "Show Custom Polyline" button, then the "Zoom to Problem Coordinates" button and you should see two line segments - one very thick and one thin. They should both be the same width as the thin line. Strangely, in the code sample I posted above, if the starting coordinates for the line are changed from -70000, -20000 to -70000, 20000 or to -140000, -40000 the line draws correctly. I'm using Flash Player 10.

View 0 Replies

ActionScript 2.0 :: Code In Flash To Read It Line By Line But Its Only Showing The First Line Out Of 5 Lines?

Dec 17, 2009

i have an xml file and i want my code in flash to read it line by line but its only showing the first line out of 5 lines.Below is the code:

var NigeriaNumber:Number;
var stateName:String;
var year:String;

[code].....

View 0 Replies

Professional :: Tricky Animation Function - Copy Paste One Of The Segments Into A Separate Layer

Oct 3, 2010

its a door make up of 8 segments, im trying to animate it by making it open and close equaly,each door segment. but my segment is distorting because im doing each one segment bt segmet.is there a way to achieve this in flash?

a):should i copy paste one of the segments into a seperate layer using that one animation i got for all 8 parts?

View 6 Replies

ActionScript 2.0 :: Create An "hitTest" Script Inside A Movieclip That Is Actually Part Of That HitTest Code?

Jan 15, 2009

i just would like to know how to create an "hitTest" script inside a movieclip that is actually part of that hitTest code?I mean... I have mc A, and mc B. and the current hitTest code im using (that is on the timeline) makes mc A, destroy mc B when collide with it... but there are many mc B on the stage (with the same instance name) so, when mc A collide with one mc B, it destroys ALL mc's B... but i want it to destroy only the mc B that he collides, not all the others... maybe an hitTest script inside a movieclip B would work (somethig like "if MC A hitTest ME = i die" (not all the others)).

View 1 Replies

ActionScript 3.0 :: Do Something After Hittest " Remove Hittest After First Collsion"?

Feb 8, 2010

i am controlling a tractor mc with right and left keyboard keys and let the user move the tractor till it reach a certain point where it touch a mc i want to go to a certain frame and stop the keyboard event listener and also the hit test listenerso finally the tractor is moved by user till it touches the mc then we will jump to a certain framethis certain frame will not have both of the tractor and the mcPHP Code:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.MovieClip;

[code].....

View 1 Replies

ActionScript 3.0 :: Setting Different Formats To Segments Of Text In A Text Field?

Dec 5, 2009

I want to assign different formatting to different segments of text in a textfield. I tried assigning a format to a string  and then concatinated it to the text and it was not accepted.How would I assign different formatting in the same textfield?
 
code follows:
format assigned to the textfield:
 
var sngTitle:TextField = new TextField();    sngTitle.text = 'Title: ';var sngTtlForm:TextFormat = new TextFormat();    sngTtlForm.font = "Stencil Std";    sngTtlForm.italic = true;    sngTtlForm.color = 0xffcc00;    sngTtlForm.size = 24;   text I want to add to the above textfield:[code]................

View 2 Replies

ActionScript 3.0 :: Line Games - Transform A Line Drawn By The Player Into A Hit Detectable Sprite ?

Feb 13, 2009

I'm trying to work out how to create a simple demo that works as follows: A ball falls from the top of the stage.Player is able to draw a line anywhere on the stage. The ball will bounce/roll along the line such that the player can guide it at will. I don't think the coordinate rotation will be a problem for me but I can't figure out how to transform a line drawn by the player into a hit detectable sprite -- or realkly any way that I can get those line coordinates into my coordinate rotation routine. To keep it simple, I'm just working on the first part of the problem, getting the line to where I can hit test or know its position.Here is my code so far:

package
{
import flash.display.Sprite;
import flash.events.MouseEvent;[code]........

It always traces 0,0 instead of my current line coordinates - and even those I don't think would be sufficient.

View 4 Replies

Professional :: Static Text After Line Break Disappears Unless At Small Line Spacings

Oct 18, 2011

in Flash CS4 I have static text like: Line1 and line2 It's in 9 point Arial Regular as a device font. If I set the line spacing below 3.9 the second line dissappears from the compiled SWF file. It still shows in the FLA file. The same thing happens at 6pt but NOT at 5pt or less.

View 1 Replies







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