PathTransition Object Collision

Hi,
I am making a game where a space shooter shoots asteroids.
I have a space shooter that shoots bullets which are simply small 3x3px rectangles. The bullets move due to a timeline keyframe calling an update function every 50ms which alters the coordinates of the bullets causing them to move across the screen.
I also have asteroids. When each asteroid (a simple grey circle) is created so is a PathTransition which moves this asteroid along a specified path starting at the time the asteroid is created.
I want to detect if a bullet has collided with an asteroid in my update function but I don't know how to tell the coordinates of my asteroid when it is moving along the path. I realise this is probably a REALLY stupid question but I just can't work it out.
Please help

Maybe you can use the Ellipse's intersects function. It should work well against a Rectangle bullet.
To answer the generic question (eg. if you want to detect collision of more complex shapes), you can get the position of the shape with its boundsInLocal variable.

Similar Messages

  • Physics Engine: How to handle object collisions / best practices?

    Right now I'm trying to find out by examining all methods and comparing to other engines like box2D how to get information about colliding objects.
    I thought I could use i.E. the "checkCollideWith" method of the btRigidBody instance, but it always returns true.
    Then, there are several interesting methods in the collisionDispatcher class, but also they don't yield any satisfying results.
    I could set a "nearCallbackFunction", but then, the collision wasn't handeled internally anymore.
    Has anyone found out how to get reliable information about colliding objects?
    Also the Pellet-Engine looks really "ported from C++", not like a typical AS3 project. I could imagine that Adobe would refactor the whole thing at a given time to make it fit more into their AS3 environment. Then, there would also be "real" events for things like that.

    Well I answered it myself. I should have noticed that "Pellet" sounds familiar. Like the physics engine used in Blender3D, "Bullet".
    And when I looked at the wiki, I found out that Pellet was a clone of Bullet so I could easily port these lines of code to AS3:
    // inside onAnimate method of BasicScene
                   var numManifolds:int = _dynamicsWorld.getDispatcher().getNumManifolds();
                   for (i = 0; i < numManifolds; i++) {
                        var contactManifold:btPersistentManifold = _dynamicsWorld.getDispatcher().getManifoldByIndexInternal(i);
                        var obA:btCollisionObject = contactManifold.getBody0();
                        var obB:btCollisionObject = contactManifold.getBody1();
                        var numContacts:int = contactManifold.getNumContacts();
                        var j:int;
                        for (j = 0; j < numContacts; j++) {
                             var pt:btManifoldPoint = contactManifold.getContactPoint(j);
                             if (pt.getDistance() < 0) {
                                  // const btVector3& ptA = pt.getPositionWorldOnA();
                                  // const btVector3& ptB = pt.getPositionWorldOnB();
                                  // const btVector3& normalOnB = pt.m_normalWorldOnB;
                                  trace ("yay, dingdingding! => " + obA + ", " + obB+ " collided!");
    I just used the code described here:
    http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Callbacks_and_Triggers
    You can get the full documentation here:
    http://www.bulletphysics.org/mediawiki-1.5.8/index.php?title=Documentation
    Probably everything will also work in Pellet this way, you've just port the code to AS3, no need to even change variable or method names, it seems to be all the same in Pellet.

  • Object collision

    im trying to get object collition working between boundaries_mc and bill_mc, but cant seem to get it working
    private function processCollisions(eventObj:Event):void
                // when player is falling
                if (billYV > 0)
                    //respawn if off stage
                    if (game_mc.bill_mc.y > stage.stageHeight)
                        game_mc.bill_mc.x = game_mc.startMarker_mc.x;
                        game_mc.bill_mc.y = game_mc.startMarker_mc.y;
                        game_mc.x = 200;
                        game_mc.y = 460;
                        billYV = 0;
                    //otherwise process collisions with boundaries
                    else
                        var collision:Boolean = false;
                        if (game_mc.boundaries_mc.hitTestPoint(game_mc.bill_mc.x, game_mc.bill_mc.y, true))
                            collision = true;
                        if (collision)
                            while (collision)
                                game_mc.bill_mc.y -= 0.1;
                                collision = false;
                                if (game_mc.boundaries_mc.hitTestPoint(game_mc.bill_mc.x, game_mc.bill_mc.y, true))
                                collision = true;
                            billYV = 0;
    all of my symbols have been placed inside game_mc, bill_mc does respawn, just doesnt collide with boundaries_mc, im getting no compiler errors :S

    Hi so what happens in your game is when you playing and you fall off an object (so are you creaing a platform game?) I've got an idea maybe instead of the boundaries you could get the position of them and maybe give the code like... (SAY IF YOUR STAGE IS 500 x 500 THEN YOU SHOULD PLACE IT LIKE THIS):
    if (your_object_mc.y > 500) {
    //what you want it
    //to do after its fallen.
    I think this happens because your boundaries dose not reconize the object EG: your_object_mc.
    I am not entierly sure but without an error code i might not be able to give the 100% right answer.
    Or maybe try with them the other way round.
    Best Regards,
    James.

  • Tiling and collision methods for this app

    I plan on making a game where the player travels down though a level. I have created basic player/objects collision games using AS2 & Mclips for browser/PC and some basic AS3 apps also, but I want to focus on making this one to run well/fast on iOS and Android via flash/AIR.
    The goal will be for the player to avoid colliding with rock/tiles.  There will not be too many enemies to track but a few powerups may be on the rock edges to pickup.
    Can someone give me any suggestions/links for current Tiling and Collision methods for this environment? Should I use starling?

    Thanks Glad, I hear that a pixel perfect collision method like bitmapdata hittest can be a tremendous overhead in CPU time, but I guess I will have to try it and see.

  • Wish list for Premiere CS6

    Please invest in getting a good slow motion plugin bundled with premiere cs6, the current slow mo is choppy at best even with frame blending. Get twixtor or other bundled with cs6 please.
    There should be a button to deactivate all plugins/effects on all clips so playback can be seemless to review an edit. We can only currently do this manually by deselecting every effect on evey clip which takes forever, there should be a generic option for all effects enable/disableon all video in the sequence.
    Multicam needs to extend from 4 cameras to at least 8 or above as with most other NLEs
    Add some alpha based transitions in the effects transitions similar to pixelan transitions
    Particle effects similar trapcode particular for effects like smoke, fire, sparks etc.
    extention to lens flare with more control over flare, flare components, rays, glow ect
    A colour corrector that will balance colour between clips ergo you have 3 separate clips and the colour temp is slightly different in each, a fast solution is needed to balance all clips. If the shots are similar there should be a way that NLE can correct colour for both so individual clips match with aid of user. A sort of balance this clip to the colour in this other clip. Again basic colour correction is always used and a very time consuming process, simlifying this will help.
    Movie sound effects bank for online content. Many people spend hours looking for or creating simple movie sound effects for fighting, inanimate object collisions, effects for impact, wooshes, trailer effects etc.
    My oppinion soo far is Adobe CS suits are great and work well together, the software IS getting better so these are just my thoughts.

    FAQ: How do I submit a bug report or feature request or otherwise give feedback about Premiere Pro?

  • Attempt to move main timeline from inside a movie clip breaks menu buttons.

    I am attempting to have the main timeline move from a stopped position over a movie clip to frame 1, where my start menu is.
    The code I'm using does move the timeline but in doing so it somehow breaks the 4 buttons I have in frame 1.
    My code in the movie clip:
    stop()
    function replayMovie(event:MouseEvent):void
    MovieClip(parent).gotoAndStop(1);
    Menu.addEventListener(MouseEvent.CLICK, replayMovie);
    My code in frame 1 of the main timeline:
    stop();
    function bo(event:MouseEvent):void
    gotoAndPlay(21)
    SoundMixer.stopAll()
    espesp.addEventListener(MouseEvent.CLICK, bo);
    function ho(event:MouseEvent):void
    gotoAndPlay(31)
    SoundMixer.stopAll()
    espeng.addEventListener(MouseEvent.CLICK, ho);
    function yo(event:MouseEvent):void
    gotoAndPlay(41)
    SoundMixer.stopAll()
    engesp.addEventListener(MouseEvent.CLICK, yo);
    function go(event:MouseEvent):void
    gotoAndPlay(51)
    SoundMixer.stopAll()
    engeng.addEventListener(MouseEvent.CLICK, go);
    The error output when I use my Menu button at the end of the movie clip.
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at SSubjunctiveProjNewgrounds_fla::MainTimeline/frame1()
    at flash.display::MovieClip/gotoAndStop()
    at SSubjunctiveProjNewgrounds_fla::Esp_5/replayMovie()
    Any help would be greatly appreciated.

    For the sake of space, I'll leave out all the package declarations and class declarations and just talk about the functions.
    First, the Game class, it has two functions.  The first one is the constructor function and it launches at the beginning of the game:  First the Game function:
    public function Game():void
    //Game code goes here
    }//Game
    We want to listen for someone to click the mouse on the MenuPage, so lets create a new MenuPage and add a listener to the button contiained within it.
    public function Game():void
    menuPage = new MenuPage;
    menuPage.startButton.addEventListener(MouseEvent.CLICK, startGame);
    addChild(menuPage);
    }//Game
    You will notice that before I declared a variable var menuPage:MenuPage, but that's all I did was declare it.  I didn't really make a new instance of it, I just set aside space for it.  In the first line within the Game function, I'm actually turning that variable into a new instance of a MenuPage.
    We don't have a picture of this imaginary menuPage instance, but lets' assume that in our MenuPage MovieClip in the library, we created a SimpleButton called startButton.  Here, I'm adding an EventListener that patiently waits for someone to click that button.  Once we receive that event, Flash is told to call the startGame function.
    As you get better at this, you'll get into custom events, and the eventListener for the button will exist in the MenuPage class file, or even in another class file that you create just for the button.  Something like StartButton.as  But for now, we can do it as above.
    Now the startGame function:
              public function startGame(evt:MouseEvent):void
    //Remove the start Page
    //Add the zombie
    //Add the gun
    }//startGame
    And we'll replace those comments with real code.  It follows along with what we just did above.
    public function startGame(evt:MouseEvent):void
    zombie = new Zombie;
    addChild(zombie);
    gun = new Gun;
    addChild(gun);
    And we also want to clean up some by removing the menuPage, and throwing out the eventListener.
    public function startGame(evt:MouseEvent):void
    zombie = new Zombie;
    addChild(zombie);
    gun = new Gun;
    addChild(gun);
    menuPage.startButton.removeEventListener(MouseEvent.Click,startGame);
    removeChild(menuPage);
    }//startGame
    Now our Game class is complete.
    The Zombie Class
    public function zombieWalk(evt:Event):void
    this.addEventListener(Event.ENTER_FRAME,zombieWalk);
    this.x = this.x + 10;
    }//zombieWalk
    Notice we've added a function to the Zombie Class.
    The first function adds an EventListener to the zombie.  We can use the word this and actionScript knows we're talking about the zombie that the class is written for.  This listener fires off every frame.  If our FLA file is set to 12fps, then 12 times every second it will call on the zombieWalk function.
    The zombie walk function moves the zombie 10 pixels to the right every time the function is called.
    On a more advanced level, you'll want to add animation in the MovieClip to move the zombie legs.  You'll also want to use Timer events to space out how often the funtion fires and not ENTER_FRAME events.  And you'll want to use a static constant to establish how far the zombie moves.  We have it now set to 10 pixels, but that can get irritating if we want to change that value later.  But again, baby steps.
    And finally, the Gun class
    public function Gun():void
    this.addEventListener(MouseEvent.CLICK, fireGun);
    }//function
    public function fireGun(evt:MouseEvent):void
    this.gotoAndPlay(2);
    }//fireGun
    First we add an EventListener for when someone clicks on the gun.  Once this happens, the listener calls on the fireGun function.
    The fireGun function takes advantage of the frames within the Gun MovieClip.  Say we have three frames in the Gun MovieClip.  The first is just a picture of the gun.  The second is the gun with a flash coming out of the nozzle.  And the third is the gun at rest again.  The line this.gotoAndPlay(2) sends the gun to the second frame with the flash graphic.
    For this to work, each frame in the Gun MovieClip has to have some stop and play commands.
    But.. you said no code on our timeline!! Liar!
    I know.  This is the exception.  You will need basic stop() commands and gotoAndPlay commands to loop animations.  Any MovieClip that has more than one frame will need something to control it.
    So our Gun MovieCLip has the following:
    Frame 1: stop();
    Frame 2: no actionScript... and I mean nothing, not even the words, "no actionScript"
    Frame 3: gotoAndStop(1);
    This will loop the gun to the beginning and wait for the next time the user clicks the gun.
    Advanced features of the Gun class might include a Bullet.as sub-class that creates a bullet MovieClip to fly across the screen.  Sound to play when the shooting takes place.  Object collision detection to see if the bullet hits the target.  And a means by which a custom event will tell the Game.as class that a zombie has been hit and it should be removed from the stage.
    As you go down the rabbit hole of ActionScript 3, you will find yourself at a point where it's just a matter of getting the syntax right for all the built in functions and classes.  Arrays, Loaders, casting variable types.. all that stuff will come.
    I hope this has been helfpul.  It's been on my to-do list for a long time.  When I first started out, no one could provide me with basic answers for how all these classes and whatnot worked.  After teaching myself AS3 for 2 years and reading a gabillion books, I think I've gotten to a point where I'm pretty comfortable with it all.

  • Organising CLass Files

    Hi guys and girls,
    Up until now I have just need to import standard flash
    classes into my projects, but now I am at the stage where I am
    needing to create my own classes......just wondering if someone has
    a view on the best way to store the external .as files? I had a
    friend ages back who was showing me his setup and it looked like he
    had a library that he was viewing inside of flash that contained
    all his classes...he was running a webserver on his laptop so maybe
    they were on his server, but I distinctly remmber him browsing his
    class files in flash.....not really sure and I don't keep in
    contact anymore so it would be good to get your guys opinion on the
    different approaches.
    Thanks and all the best,
    Nathan..

    Nathan,
    > I am at the stage where I am needing to create my own
    > classes......just wondering if someone has a view on the
    > best way to store the external .as files?
    I recommend a package based on your domain name, including
    folders for
    categories if it makes sense (e.g. my own classes are in the
    net.quip
    package -- and if I feel the need for additional
    categorization, I use
    net.quip.utils [etc.]). Make sense? Domain names are unique,
    so this
    avoids possible object collisions.
    > I had a friend ages back who was showing me his setup
    > and it looked like he had a library that he was viewing
    inside
    > of flash that contained all his classes...
    Possibly the Project panel?
    Here's an article I wrote not too long ago on classpaths for
    AS2.
    http://www.communitymx.com/abstract.cfm?cid=197DE
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • First person perspective room

    What is the feasibility of creating a first person
    perspective room in flash/as? My company has a requirement to
    create a virtual branch (I work for a bank) and have a client go in
    and use the arrow keys to move around the room, approach a teller
    and interact with a 3d model with sequenced animation. I am so new
    at flash I dont know what is possible, but I have seen 3D worlds
    where you can walk around (albeit simplistic) with object
    collision. The only drawback was that the coding was complicated.
    Has anyone done this and or has any ideas as to where I
    should be looking to find out more on how to do this
    project?

    I'm doing something similar but I'm building the room/space
    in Cinema4D and using, ultimately, flv files. I would think you
    could film the simple sequences in the bank with a basic digital
    camera and then use a form of rotoscoping or just tracing keyframes
    of the video with vector lines.
    But, you'll have to create animations of the teller which
    isn't easy to do unless you do that sort of thing. Maybe buying
    pre-existing models would be easier to do.
    Sounds like it might be quite a bit to chew for a
    beginner!

  • I'm trying to make an android game and I want that when a collision with another object change of sc

    I'm trying to make an android game and I want that when a collision with another object change of scene
    how i can do this

    here is the doc on htiTestObject for detecting collisions.
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayOb ject.html#hitTestObject()
    for scene change use the second parameter in gotoandplay() to define scene name doc below
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/MovieClip .html#gotoAndPlay()

  • What is the best way to test for collisions between objects?

    I am in the process of developing my first game, my first decent game that is. I understand how to develop the background and tileset for the game, but have yet to figure out an effective way of testing for collisions. As in you try to move the character into a wall, or another object on the level.
    If I divide the level into tiles, it won't be to hard, but I am thinking I want to have the hero be able to move all over the place, not just from square to square.
    Any suggestions or ideas will be greatly appreciated

    If I divide the level into tiles, it won't be to hard,
    but I am thinking I want to have the hero be able to
    move all over the place, not just from square to
    square.Err...
    So if the hero is not on a square, the hero is not on a tile and consequently is not on a visible aspect of the game world?
    I suspect that you wanted the hero to be able to move in any direction, not just the standard cardinal directions.
    If you're using tiles to represent the game world, then the solution is simple - check to see if there's anything "solid" already on the target tile. If there is, abort the move and report it as a collision. If there isn't, permit the move.
    It's only when you have a tile-less world that you actually have to determine if the leading edge of your hero crosses the boundary of an item (or border) that he shouldn't be allowed to cross. Doing so is complicated enough that I would simply suggest that you search the forum for third party collision detection packages that you can borrow.

  • Rotating and Translating Objects with Collision Modifiers

    Hello
    Im trying to build a simple 3d scene. The idea being that a
    footballer walks up to a football and on detection of that
    collision, the football is translated or 'kicked.'
    Got the Collision Detection working using Collision
    Modifiers. Got it working so that it registers the collisions, what
    I havent gotten is how to translate the object (football) I have
    used the simple translate command but this seems to work on objects
    without collision modifiers.
    Does anyone have any work arounds?
    Thanks in Advance

    Hello
    Im trying to build a simple 3d scene. The idea being that a
    footballer walks up to a football and on detection of that
    collision, the football is translated or 'kicked.'
    Got the Collision Detection working using Collision
    Modifiers. Got it working so that it registers the collisions, what
    I havent gotten is how to translate the object (football) I have
    used the simple translate command but this seems to work on objects
    without collision modifiers.
    Does anyone have any work arounds?
    Thanks in Advance

  • How to create collision system which allows player to push object

    Hi guys,
    For the game I'm making, I wanna set up a game mechanic/feature where  the player can push blocks around the level but currently having  problems setting the collision system to do this. I've been trying to  use method call (shown below) which uses a collision class I've created,  works fine for the enemies, but not for blocks objects for some reason.
    Collision.block(block, player);
    Anyway I thought I should go with a different direction setting  the collision/push for the block objects, I was wondering anyone had any  suggestions to do this? Perhaps HitObject method call? Any help and  tips would be greatly appreciated:)
    Thanks
    Jonesy

    Hi,
    There is Portal content for SRM.
    http://service.sap.com/patches
    Regards,
    Masa

  • Collision with objects load from Maya( *.obj)

    Hello everybody
    I want check collist with objects which load from Maya file ( *.obj)
    how will i do ?
    Can you help me
    if some body has code about this please post to forum or sent to me
    my email : [email protected]
    Thanks you so much

    It doesn't matter where the objects came from once they have been loaded into java3d.
    Look for tutorials on collision detection and in the javadocs on bounds and picking.

  • Managing multiple collision detection between objects(not necessarily circles)

    Hi.
    I´d like to know if there´s any good tutorial, or if somebody knows, a way, to manage a multiple collision detection with pixel level detection, for objects, not necessarily circles, irregular objects.
    Any help?

    Yes, and what about the speeds of each object?
    I was thinking something like this:
    var  _currentObj1SpeedX = obj1.speedX
    var  _currentObj1SpeedY = obj1.speedY
    obj1.speedX = obj1.speedX - obj2.speedX
    obj1.speedY = obj1.speedY - obj2.speedY
    obj2.speedX = obj2.speedX -  _currentObj1SpeedX
    obj2.speedY = obj2.speedY -  _currentObj1SpeedY
    Is it right?

  • Collision with rotated object?

    Hi!
    I am currently making a game based on slicing other objects, basiclly when you hold down and drag your mouse and then release it an object that shows the cut will be created.
    Sorry if its hard to explain :S maybe some code will be more appealing:
    //Sliceline.as
    package 
              import flash.display.Bitmap;
              import flash.display.Sprite;
               * @author @SaUrOnZ
              public class SliceLine extends Sprite
                        private var sliceT:SliceTexture;
                        public function SliceLine(fromX:Number, fromY:Number,rotation:Number, length:Number)
                                  sliceT = new SliceTexture();
                                  addChild(sliceT);
                                  sliceT.x = fromX;
                                  sliceT.y = fromY;
                                  sliceT.width = length;
                                  sliceT.rotation = rotation;
                                  /*graphics.clear();
                                  graphics.lineStyle(2, 0xFFFFFF);
                                  graphics.moveTo(fromX, fromY);
                                  graphics.lineTo(toX, toY);*/
    Code for collision:
    //Main.as
    if (sliceArray[s].hitTestObject(cube))
                                                      cube.hit();
                                            }else {
                                                      cube.nohit();
    When my object is created it will be rotated, width & height corrected accordingly to the mouse initial and ending positions.
    Here is a screenshot to help you understand how it looks like:
    Now comes the problem. When i try to make it collide with another object it seems the bounds of the object increase when dragged diagonaly. While using it straight up/down/left/right the collision seems to be almost perfect.
    Screenshot of up/down/left/right collision (green means not collided and red is collided):
    Screenshot of diagonal collision (green means not collided and red is collided):
    Is there some kind of way to make the diagonal collision work?
    Any help is highly appreciated.
    Many thanks, Erik Jansson

    that's expected behavior from hitTestObject:  your testing if the bounding boxes are hitting.
    to use a shape-based hittest, use the bitmapdata's hittest.

Maybe you are looking for

  • Problem: The same filename from a sender to a receiver file adapter - SP14

    Blog : /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14 My Problem: The thing works for me and i am able to get my input files name as my output file name. But one thing i noticed is that in

  • Change condition value in PO after GR

    HI all, how can i change the freight condition value  in PO after making  GR for partial quantity. we want to change the freight for the next GR. thanks

  • 0FI_AR_4 Extractor Enhancement without user exit code Question

    Hi I have a requirement to enhance 0FI_AR_4 Extractor with below Fields from BSID: Field     DataElement PRCTR       PRCTR VPOS2       NUM06 VBUND       RASSC As per SAP Note: 410799, I am assuming I don't need to write any ABAP code to populate thes

  • How can I check the progress of a Loader from within a movie clip?

    Hi All, I have a Loader called profileContentLoader that I create in AS3 on the main timeline, I would like to check the bytesLoaded of profileContentLoader from within a movieclip thats in another movieclip.... I tried: MovieClip(root).profileConten

  • How to make a contact sheet in bridge

    Hi, I'm new to using bridge.  I'm taking a photography class this semester and I need to make a contact sheet.  The professor showed us, very quickly, how to do it and now I'm lost. Any help will be appreciated.  I'm running Bridge CC Thanks Travis