Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 45
Like Tree3Likes

Thread: My game isn't working

  1. #21
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    All the 9 images are there in the Src folder and Bin folder.

  2. #22
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,965
    Rep Power
    31

    Default Re: My game isn't working

    If the images in the jar file are in a folder, then the path in the getResource() method must include that path.
    If you don't understand my response, don't ignore it, ask a question.

  3. #23
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    Could you give a example Sir?
    For example:
    I got this line of code:
    refEnemy = new ImageIcon(getClass().getResource("Asteroid.png"));
    The getResource should be like this? getResource("folderName\asteroid.png") ?

  4. #24
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,965
    Rep Power
    31

    Default Re: My game isn't working

    The getResource should be like this? getResource("folderName\asteroid.png") ?
    Like this with / vs \
    getResource("folderName/asteroid.png")
    sancho likes this.
    If you don't understand my response, don't ignore it, ask a question.

  5. #25
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    Java eclipse is not finding the images.

    I tried:
    refEnemy = new ImageIcon(getClass().getResource("/new/src/APS/bin/aps/jogo/Asteroid.png"));
    and
    refEnemy = new ImageIcon(getClass().getResource("jogo/Asteroid.png"));
    no sucess

  6. #26
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: My game isn't working

    Do any of your resource grabs work? If so, you can print out the path name and see what is going on.

    I also noticed this path name in your source code zip file

    /new/bin/APS/bin/aps/jogo/Asteroid.png

    Regards,
    Jim
    Last edited by jim829; 11-23-2016 at 07:42 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #27
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,965
    Rep Power
    31

    Default Re: My game isn't working

    You said:
    All the 9 images are there in the Src folder and Bin folder.
    But the code you show in post#25 did not use either of those folders: Src and Bin

    Inside the jar file: what folder is the Asteroid.png file in? What is the full path to that file?
    If you don't understand my response, don't ignore it, ask a question.

  8. #28
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    Game.zip\APS\bin\aps\jogo\Asteroid.png

    and

    Game.zip\APS\src\aps\jogo\Asteroid.png

  9. #29
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,965
    Rep Power
    31

    Default Re: My game isn't working

    Are those the paths in the jar file?

    What is the Game.zip\ at the start of the path? Is that what is in the jar file?

    Is the class that is calling getResource in a package?
    Then the path should start with a /
    Last edited by Norm; 11-23-2016 at 07:45 PM.
    If you don't understand my response, don't ignore it, ask a question.

  10. #30
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    I extracted the Jar file with winrar, that's why the Game.zip, and it is in a folder.

    I'm sorry but i gotta show the image and it's not working:

    My game isn't working-sem-t-tulo.jpg

  11. #31
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,965
    Rep Power
    31

    Default Re: My game isn't working

    Is the class with the call to getResouce in a package?
    If you don't understand my response, don't ignore it, ask a question.

  12. #32
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    Yes, it is! I made another folder with the images just to make sure.

  13. #33
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,965
    Rep Power
    31

    Default Re: My game isn't working

    Is the class with the call to getResouce in a package?
    I am asking if there is a package statement at the start of the class's source file.
    What is the contents of that statement?
    If you don't understand my response, don't ignore it, ask a question.

  14. #34
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: My game isn't working

    First, that structure just looks wrong for a jar file.
    But maybe that's how you've written it. It's just a bit confusing.

    If you are trying to get at a resource starting at the root of the jar file then you need to stick a '/' at the start, otherwise it is trying to look for the resource based on the current class's package.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  15. #35
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    Yes there is a statement.

  16. #36
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,965
    Rep Power
    31

    Default Re: My game isn't working

    What is the contents of that statement?

    Did you try adding a '/' at the start of the path in the getResource call?
    If you don't understand my response, don't ignore it, ask a question.

  17. #37
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    Like this:
    new ImageIcon(getClass().getResource("/Asteroid.png"));
    ?

    I already try. Like a said sir, i'm a novice, i'm not good to catch errors...

    The package
    package APS.src.aps.jogo;
    ,the class is in it, and
    have all the imagens too, the game is working in the eclipse without problems or erros.

    Could you please try to run the Runnable Jar in you pc? Just to a fast look?You got more experience, i'm a novice in this world.

  18. #38
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,965
    Rep Power
    31

    Default Re: My game isn't working

    new ImageIcon(getClass().getResource("/Asteroid.png"));
    ?
    That is for the image file to be at the root level. If the image file is not at the root level, then the path (inside the jar file) to the image file needs to be included in getResource call:
    Java Code:
    new ImageIcon(getClass().getResource("/<thePathHere>/Asteroid.png"));
    If you don't understand my response, don't ignore it, ask a question.

  19. #39
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    I did it and the game continues to stops at the score 149.

  20. #40
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,965
    Rep Power
    31

    Default Re: My game isn't working

    What is it supposed to do?

    What does "stops at the score 149" mean?
    Does that mean the game works correctly for score 0 and score 1 and score 2 etc up to score 148?
    If you don't understand my response, don't ignore it, ask a question.

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Tic Tac Toe game - winning logic not working.
    By Mikki in forum New To Java
    Replies: 21
    Last Post: 11-05-2012, 08:51 PM
  2. working on a pacman game need help
    By paris72 in forum Java Gaming
    Replies: 2
    Last Post: 06-04-2012, 10:04 AM
  3. Game using swings not working
    By humanbeing in forum Java Gaming
    Replies: 7
    Last Post: 10-06-2010, 03:04 PM
  4. Game Help.working on it for days,.
    By xSkittlesx in forum Java Applets
    Replies: 12
    Last Post: 05-31-2010, 03:24 PM
  5. Gueesing Game Almost done, but not working correctly
    By mbnumba6 in forum New To Java
    Replies: 5
    Last Post: 03-18-2009, 03:01 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •