Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4554358
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:04:42+00:00 2026-05-21T17:04:42+00:00

For a class project I’m working on Pissed Off Pigs (I think you get

  • 0

For a class project I’m working on “Pissed Off Pigs” (I think you get the idea, the pigs get revenge, don’t worry, I’m not going to release it!) and I want to create circles with a fill from a bitmap (circles because the collision math is easier). Here is how they look now.

How my Pigs look now

Of course, the white is the problem. Below is my “pigs” class. Any ideas? I’ve tried gif’s, pngs, 8-bit pngs, etc and it seems to make no difference. The image itself is 20px square and the radius of the circle is 10px (so a 20px diameter). Here is the image I’m using: My Pig Image

And I know I should probably load the image outside the class and just pass the BitmapData when I make a new pig so I don’t have to load the image every time I create a new pig but for now it works! (Sorta).

Is the matrix translate the problem?

Oh, and I have checked bmpImage.transparent and it returns true (even when I don’t specify true in the constructor).

`
package {
import flash.display.;
import flash.net.
;
import flash.events.;
import flash.geom.
;
import flash.display.BitmapDataChannel;

public class pig extends Sprite {
    public var radius:uint;
    public var velocity:Vec2;
    public var tt:Sprite;
    public var pigLoader:Loader;
    public var bmpImage:BitmapData;
    public var framesAlive:uint;


    public function pig(xx:uint, yy:uint, radius:uint, vx:Number, vy:Number, sprite:String){
        this.x = xx;
        this.y = yy;
        this.radius = radius;

        this.velocity = new Vec2(vx, vy);

        pigLoader = new Loader();
        pigLoader.load(new URLRequest(sprite));
        pigLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, picLoaded);

    }
    private function picLoaded(event:Event):void {
        bmpImage = new BitmapData(pigLoader.width, pigLoader.height, true);
        bmpImage.draw(pigLoader);
        tt = new Sprite();
        var matrix:Matrix;
        matrix = new Matrix();
        matrix.translate( -10, -10);
        tt.graphics.beginBitmapFill(bmpImage, matrix, false, false);
        tt.graphics.drawCircle(0, 0, this.radius)
        tt.graphics.endFill();
        this.addChild(tt);
    }
}

}

`

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:04:42+00:00Added an answer on May 21, 2026 at 5:04 pm

    You’ve way overcomplicated the problem. Bitmap fill is normally used when you want to fill a large area with a tiled pattern, and the pattern is coming from a bitmap (think wallpaper), you don’t need to use it here. What you should be doing is using the Loader.content Bitmap. You don’t need the draw() or the matrix, just use .x and .y to move your pig Bitmap centered over your Sprite’s (0,0) point if that’s the center of the circle you’re using for collision detection.

    There is no reason for your pig sprite to have a visual circle for you to use circle-based collision detection. The visual representation should not matter to your collision detection at all. Circle-based collision detection is normally just an application of the Pythagorean distance formula, i.e. if the distance between centers is less than (or equal to) the sum of the radii of the circles being tested, you have overlap (collision).

    What if you replace that last function with this:

    private function picLoaded(event:Event):void
    {
        var pigPic:Bitmap = event.target.loader.content;
        pigPic.x -= 10;
        pigPic.y -= 10;
        this.addChild(pigPic);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a class project to build a little Connect4 game in Java.
I'm working on a class project which is using a Kinect. According to the
I've been working on my final programming class project, and I am stuck right
I have entity class: public class Project { public virtual int Id { get;
I'm currently working on a class project, and we're doing a basic implementation of
So I have this demo project almost completely working. public class Project { public
First, I have two project working on: ASP.NET and Silverlight Both uses a class
So I'm working on a class project that uses MFC. I never had to
So I'm working on a class (all the students in the class) project (I
I'm working on creating two classes for a sort of useless class project. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.