Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Bitmap Collision won't work?

Participant ,
Feb 13, 2014 Feb 13, 2014

It Hits when it isn't even touching, I think it tends to hit when it vertically lines up with the ship

Main.as

                        override public function Updates():void

                    {

                         //Collision

                              for(var i:int=0; i<Main.game_state.object_spawner.ObsticleArray.length; i++)

                              {

                                        if(game_state.ship.ShipBD.hitTest(new Point(game_state.ship.x, game_state.ship.y), 255, game_state.object_spawner.ObsticleArray.SatiliteBD, new Point(game_state.object_spawner.ObsticleArray.x, game_state.object_spawner.ObsticleArray.y), 255))

                                        {

                                                  trace("Hit");

                                                  PlayerDead = true;

                                        }

                              }

                    }

ship.as

               public var ShipBD:BitmapData;

            public var ShipBMP:Bitmap;

                         ShipBD = new BitmapData(Ship_Texture.width, Ship_Texture.height, true, 0x00000000);

                              ShipBMP = new Bitmap(ShipBD);

                              ShipBD.draw(Ship_Texture);

                              addChild(ShipBMP);

                              ShipBMP.width = 115;

                              ShipBMP.height = 150;

Obsticle.as

                         public var SatiliteBD:BitmapData;

                    public var SatiliteBMP:Bitmap;

                         SatiliteBD = new BitmapData(Satilitetexture.width, Satilitetexture.height, true, 0x00000000);

                                        SatiliteBMP = new Bitmap(SatiliteBD);

                                        SatiliteBD.draw(Satilitetexture);

                                        addChild(SatiliteBMP);

                                        SatiliteBMP.width = 100;

                                        SatiliteBMP.height = 100;

Thanks

TOPICS
ActionScript
461
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 13, 2014 Feb 13, 2014

why aren't you using the bitmapdata hittest on two bitmapdata objects?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 14, 2014 Feb 14, 2014

how?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2014 Feb 14, 2014
LATEST

var mat:Matrix;

var shipBMPD:BitmapData=new BitmapData(stage.stageWidth,stage.stageHeight);

.

.

.

mat=game_state.ship.transform.matrix;

shipBMPD.draw(game_state.ship,mat);

if(game_state.ship.ShipBD.hitTest(shipBMPD))

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines