We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Someone please help me! I keep getting this error.
Page Index Toggle Pages: 1
Someone please help me! I keep getting this error. (Read 976 times)
Someone please help me! I keep getting this error.
Nov 5th, 2009, 6:51pm
 
I have a program thats due tomorrow but I can't get past this error! "x cannot be resolved or is not a field?". Why does this keep popping up? Would it be better if I showed you more code?

for(int i=enemies.size()-1; i>=0; i--){
     Enemy peng = (Enemy) enemies.get(i);

     float dis = dist(x,y, peng.x,peng.y);
     float addedRadii = 8+diameter/2;
     TowMiliSec++;

     if(dis <= addedRadii){
       smallest = min(smallest, i);
     }
   }
   
   float biggestFac = max(x-enemies.get(smallest).x, y-enemies.get(smallest).y);
   float fac = biggestFac/3;
Re: Someone please help me! I keep getting this error.
Reply #1 - Nov 5th, 2009, 9:47pm
 
what exactly is x-enemies and y-enemies, two other classes beside enemies ?

or is there just enemies and you trying to get the x and y coordinate stored in this class. in this case try.

Enemy peng = (Enemy) enemies.get(smallest);
float biggestFac = max(enemies.x, enemies.y);
Re: Someone please help me! I keep getting this error.
Reply #2 - Nov 5th, 2009, 10:28pm
 
This little piece of code is actually written in another class (ArrayList) with it's own x & y. I am trying to subtract this x/y with the x/y of the Enemy.

class one{
int x1,y1;
}

class two{
int x2,y2;

Previous Code: max(x1-x2, y1-y2);
}


Kinda like this... except I know this wont work, but just an analogy.
Re: Someone please help me! I keep getting this error.
Reply #3 - Nov 5th, 2009, 10:41pm
 
is the code really long or can you offer a running version ? or not running in this case.
Re: Someone please help me! I keep getting this error.
Reply #4 - Nov 6th, 2009, 1:28am
 
On the face of it I think it should work: assuming the code up to the biggestFac declaration runs then it has already successfully accessed x and enemies.x.  Perhaps do as Cedric suggests and assign the enemies.get(smallest) to an Enemy variable before trying to access the properties.

Otherwise I'd check the value of 'smallest' after the for loop to make sure you're actually accessing a valid entry in the enemies array.  If that isn't the problem, as Cedric suggests, you need to post more code to put this in context.
Page Index Toggle Pages: 1