Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: My Game Sprite does not appear to be transparent with the background. Whats wrong?

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default My Game Sprite does not appear to be transparent with the background. Whats wrong?

    How do I make it so the character sprite blends with the background?



    Very much appreciate any help given.

    heres the code

    import java.awt.*;
    import java.awt.event.*;

    import acm.graphics.*;
    import acm.program.*;

    public class blueBall extends GraphicsProgram{

    public void run(){


    GImage block = new GImage("block.jpg");
    GImage bg = new GImage("bg.png");
    GImage mario =new GImage ("mario2.png");

    add(block,0,200);

    add(bg);
    add(mario,100,171);
    }
    }
    Last edited by warnexus; August 19th, 2011 at 02:27 PM. Reason: entering code


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: My Game Sprite does not appear to be transparent with the background. Whats wrong

    You have not given enough information at all. I presume the sprite is from an image...does this image allow transparency (gif, png)?

  3. #3
    Junior Member
    Join Date
    Jan 2011
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: My Game Sprite does not appear to be transparent with the background. Whats wrong

    Quote Originally Posted by copeg View Post
    You have not given enough information at all. I presume the sprite is from an image...does this image allow transparency (gif, png)?
    i have added the code. the sprite is basically an object of a GImage class.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: My Game Sprite does not appear to be transparent with the background. Whats wrong

    so the character sprite blends with the background?
    Are you asking how to make the gray border around the figure in the image be transparent?
    Do you have a photo editor that you could use to make those changes?

    Not many of us are familiar with the classes in the acm package that you are using.
    Can you convert your program to use the Java SE classes?

Similar Threads

  1. Is it possible to make a background to in image transparent
    By Zein in forum Java Theory & Questions
    Replies: 10
    Last Post: June 13th, 2011, 04:18 AM
  2. could you tell me whats wrong....
    By gonfreecks in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 6th, 2010, 04:35 PM
  3. whats wrong with this one....
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: October 6th, 2009, 10:08 AM
  4. help whats wrong
    By silverspoon34 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 3rd, 2009, 01:41 AM
  5. [SOLVED] whats wrong with my IDE
    By chronoz13 in forum Java IDEs
    Replies: 2
    Last Post: August 27th, 2009, 06:34 AM