Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  arguments of unequal length?  (Read 1563 times)
0 Members and 1 Guest are viewing this topic.
Offline westloar

Junior Member





« Posted 2012-04-27 08:46:29 »

Ok so I initialise the class Boomerang like so:

1  
boom = new Boomerang(PWIDTH, PHEIGHT, bricksMan, imsLoader, (int)(period/1000000L));


This is the class with constructor:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
public class Boomerang extends Sprite
{
    private static double DURATION = 0.5;  // secs
   // total time to cycle through all the images
   private int period;    // in ms; the game's animation period
   private BricksManager brickMan;
    private Point[] boomPath;
   


public Boomerang (int w, int h, Bricks Manager bm, ImagesLoader imsLd, int p){

 
    }
}


The amount and type of arguments are correct, yet my IDE still tells me they aren't and it won't compile because of that, am I missing something obvious (I usually am)?
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #1 - Posted 2012-04-27 08:51:00 »

After a click look it seems fine, but I cannot be sure since I do not know all of the types of your variables.

Are you using eclipse? if so then I have this problem all the time, eclipse will throw a hissy fit and you will just have to play along and try to find a way to make it happy. try selecting everything, cutting it, and then pasting it right back in the same spot, or something of that nature, often just the complete change it code will make it happy.

I honestly don't know why this happens, and if anyone knows a better solution, I would really like to know because this happens to me very often and it is a PITA!

hope I helped,
h3ckboy
Offline westloar

Junior Member





« Reply #2 - Posted 2012-04-27 08:53:57 »

I'm using netbeans and cutting and pasting the code both individual variables and the whole argument hasn't worked Sad
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline StumpyStrust
« Reply #3 - Posted 2012-04-27 09:01:43 »

...umm in your args you have "Bricks Manager" it should be "BricksManager" right? that space will throw it off because classes I don't think are suppose to have a space in their name.

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #4 - Posted 2012-04-27 09:03:16 »

yeah, stumpy is probably right, AFAIK you cannot have class names with spaces in them, so maybe it is treating htem differently.
Offline westloar

Junior Member





« Reply #5 - Posted 2012-04-27 09:12:42 »

yer that was a typo

ok so that fixed the problem initialising it.

BUT

 now it says there are no arguments in the actual class....

Here's the log:

1  
2  
3  
4  
5  
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Users\charlotte\Documents\NetBeansProjects\LabRat\src\labrat\Boomerang.java:27: error: constructor Sprite in class Sprite cannot be applied to given types;
public Boomerang (int w, int h, BricksManager bm, ImagesLoader imsLd, int p){
  required: int,int,int,int,ImagesLoader,String
  found: no arguments
Offline StumpyStrust
« Reply #6 - Posted 2012-04-27 10:10:21 »

Know this sounds very obvious but have you not saved it? It looks like it is pulling files/data from an older save hence why it needs ints and then some other stuff.

Do you remember any method with that argument? int int int int ImagesLoader String

If it was an old method that you changed then it is most likely not getting the new files.


Offline westloar

Junior Member





« Reply #7 - Posted 2012-04-27 10:58:21 »

ok, so now it's asking for the arguments of the superclass not the boomerang class, I already have a class that extends Sprite and doesn't use its arguments, any ideas?
Offline StumpyStrust
« Reply #8 - Posted 2012-04-27 11:08:11 »

hmmm I am still confused on how your code structure looks like. You may be doing something wrong with inheritance.

Also, can you show what boom is? Is it Boomrang boom; or something else boom;


Offline westloar

Junior Member





« Reply #9 - Posted 2012-04-27 11:17:14 »

this is the super class, Sprite:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
public class Sprite 
{
  // default step sizes (how far to move in each update)
 private static int XSTEP = 5;
  private static int YSTEP = 5;

  // default dimensions when there is no image
 private static final int SIZE = 12;  

  // image-related
 private ImagesLoader imsLoader;
  private String imageName;
  private BufferedImage image;
  private int width, height;     // image dimensions

  private ImagesPlayer player;  // for playing a loop of images
 private boolean isLooping;

  private int pWidth, pHeight;   // panel dimensions

  private boolean isActive = true;      
  // a sprite is updated and drawn only when it is active

  // protected vars
 protected int locx, locy;        // location of sprite
 protected int dx, dy;            // amount to move for each update



  public Sprite(int x, int y, int w, int h, ImagesLoader imsLd, String name)
  {


Boomerang extends Sprite.

Here is another class that extends sprite but does not have this issue:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
public class JumperSprite extends Sprite
{
  private static double DURATION = 0.5;  // secs
   // total time to cycle through all the images

  private static final int NOT_JUMPING = 0;  
  private static final int RISING = 1;  
  private static final int FALLING = 2;  
  // used by vertMoveMode
 //  (in J2SE 1.5 we could use a enumeration for these)

  private static final int MAX_UP_STEPS = 8;
    // max number of steps to take when rising upwards in a jump


  private int period;    // in ms; the game's animation period

  private boolean isFacingRight, isStill;

  private int vertMoveMode;
    /* can be NOT_JUMPING, RISING, or FALLING */
  private int vertStep;   // distance to move vertically in one step
 private int upCount;

  private BricksManager brickMan;
  private int moveSize;   // obtained from BricksManager

  private int xWorld, yWorld;
    /* the current position of the sprite in 'world' coordinates.
       The x-values may be negative. The y-values will be between
       0 and pHeight. */

 

  public JumperSprite(int w, int h, int brickMvSz, BricksManager bm,
                                        ImagesLoader imsLd, int p)
  {
    super(w/2, h/2, w, h, imsLd, "robStandRight");


does that help?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #10 - Posted 2012-04-27 11:21:43 »

Are you calling super(...) in Boomerang's constructor?

How about showing us all of the code with issues, rather than tiny bits and hiding the real problem?  Tongue

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline westloar

Junior Member





« Reply #11 - Posted 2012-04-27 11:25:39 »

No, I only call super in the class JumperSprite, not in the constructor.

Do you want the whole class lol? I'll pastebin it if needed?
Offline deathpat
« Reply #12 - Posted 2012-04-27 12:32:19 »

No, I only call super in the class JumperSprite, not in the constructor.

Do you want the whole class lol? I'll pastebin it if needed?

hi,

Orangy Tang is right, you have to call the super constructor in Boomerang, otherwise java will try to call the default one from Sprite ( without arguments ) ... and you don't have any.

work in progress : D A E D A L U S
Offline westloar

Junior Member





« Reply #13 - Posted 2012-04-27 16:40:13 »

I told you I always miss something obvious, the fact it was asking for Boomerang's args first completely through me off lol.

Thanks guys it works now Smiley
Offline StumpyStrust
« Reply #14 - Posted 2012-04-27 21:57:44 »

Hehe glad you got it working. I know of many times where it was not compiling I was like  Shocked and it always turns out to be something silly.

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #15 - Posted 2012-04-27 22:59:35 »

Now we've solved the simple problem, onto something more fundamental - inheriting Boomerang and JumperSprite from Sprite is Bad and Wrong.

A boomerang is not a sprite, it's a tangible object which happens to have a visible representation. That should probably be coded by a Boomerang class which has a Sprite as a member, not inheriting from Sprite.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (23 views)
2014-08-19 00:29:53

Tekkerue (22 views)
2014-08-15 21:45:27

Tekkerue (21 views)
2014-08-15 21:22:17

Tekkerue (12 views)
2014-08-15 21:20:21

Tekkerue (19 views)
2014-08-15 21:12:11

Rayexar (57 views)
2014-08-10 17:49:23

BurntPizza (37 views)
2014-08-09 12:09:32

BurntPizza (29 views)
2014-08-07 17:01:56

Norakomi (36 views)
2014-08-06 10:49:38

BurntPizza (66 views)
2014-08-02 17:57:17
List of Learning Resources
by Longor1996
2014-08-16 01:40:00

List of Learning Resources
by SilverTiger
2014-08-05 10:33:27

Resources for WIP games
by CogWheelz
2014-08-01 07:20:17

Resources for WIP games
by CogWheelz
2014-08-01 07:19:50

List of Learning Resources
by SilverTiger
2014-07-31 07:29:50

List of Learning Resources
by SilverTiger
2014-07-31 07:26:06

List of Learning Resources
by SilverTiger
2014-07-31 02:54:12

HotSpot Options
by dleskov
2014-07-07 16:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!