From yesterday I was looking for a way to disable some behaviour in Gdx-Ai, I wrote code like this:
arriveSteeringBehaviour = new Arrive<Vector3>(character, MainCharacter.getTarget()) //
.setTimeToTarget(0.1f)
.setArrivalTolerance(0.0002f)
.setDecelerationRadius(8);
arriveSteeringBehaviour.setEnabled(true);
character.setSteeringBehavior(arriveSteeringBehaviour);
when "Arrive Distance" <= "Deceleration Radius" I'm trying to disable the Arrive Behaviour like this
if (arriveSteeringBehaviour.getDistance() <= arriveSteeringBehaviour.getDecelerationRadius() ) {
arriveSteeringBehaviour.setEnabled(false);
character.setSteeringBehavior(null);
}
but it's doesn't worked, character object still moving around, anyone can figure this out? thanks
note: in update method, I did disable any translation also disabled character.update(GdxAI.getTimepiece().getDeltaTime()); line.
Related
I'm trying to make changes to my Session servlet and they won't take effect. Basically I've written this:
isUserConfirmed = false;
if(isUserConfirmed) { do code }
else { do code }
For some reason isUserConfirmed is coming back true although I've give it a static value of false.
I'm trying to debug something and I've run into this rather annoying problem.
Help will be much appreciated.
This has been bugging me for the last couple days, because it used to work. I upgraded my intellij and now it doesn't work. I don't want to go back, but I need an answer.
So, I'm writing a console application, and while it runs, I want to have a shell'd out display of progress. It works fine when it's running, but when I'm debugging in IntelliJ Idea, the System.out.flush() won't flush to the console unless the buffer contains a newline. I wrote the following unit test to find out if it was me or my application.
#Test
public void flushTest() {
int loops = 100;
for (int i = 0 ; i < 100 ; ++i) {
System.out.print("This is a print, does it flush : " + i + "\r");
if (i %10 == 0) {
System.out.print("\n");
}
System.out.flush();
}
}
Spoiler, it is the application. I don't know what's changed, but it makes it very difficult to debug display issues without doing a full build and running on the command line. If someone can help me figure out why this changed and/or help me fix it so It'll flush properly, I'd be very grateful.
Tested on version 2016.3.5, the problem is still there.
The bug is caused by all characters after "\r" will be cleared in the console.
For example, using a string "Test\r" will be got "Test" written to console, after cursor is moved to the left by the "\r", all the characters "Test" is cleared. So you won't see anything.
The workaround is to move "\r" to the beginning of the string. For example, "\rTest" will see the output in console.
The following codes will illustrate the bug. You will see "0000" and "111" will appear for 1 second and then all are cleared by "22".
System.out.print("0000\r");
Thread.sleep(1000);
System.out.print("111\r");
Thread.sleep(1000);
System.out.print("22\r");
Until this issue is not resolved, current workaround is to use
-Deditable.java.test.console=true (specify it in idea.properties).
I have a weird problem debugging an android application.
To be accurate, I copy here the exact code I'm running on:
// Get the puzzles from cache
List<PuzzleDetails> newPuzzles = m_cachedPuzzles.getPuzzles(count);
if(newPuzzles.size() > 0){
// Remove from cache
m_cachedPuzzles.removePuzzles(newPuzzles); // LINE (A)
// Add the new puzzles from cache immediately
m_ownedPuzzles.addPuzzles(newPuzzles);
Log.d("requests", "" + newPuzzles.size() + " moved from cache to user");
}
int left = count - newPuzzles.size();
String deviceId = ResourcesPublisher.getInstance().getDeviceId();
// Don't let anyone else use these points for now
ChallengePointsManagerImpl.getInstance().usePoints(left);
Log.d("requests", "aquirePuzzles(" + left + ")");
// Get a list of requests for 'left' number of puzzles
RequestList reqList = getRequestList(left);
// TODO this is a bug, now
if(reqList.size() > 1){
reqList = getRequestList(left); // LINE (B)
}
When I run on this code, after stepping over the line (A)
m_cachedPuzzles.removePuzzles(newPuzzles);
The debugger "jumps" to the last line (B)
reqList = getRequestList(left);
A simple check shows it really skipped all code between these code lines.
For example the Log.d(...) was never called nor written.
Can anyone give me a clue why does it happen???
Thanks!
Try to do a right click > refresh on the project as it appears on the Project Explorer after you compile the code and before you start debugging.
Perhaps an exception was thrown from line A, and the next step corresponds to it closing off this stack frame?
mIsReaded = (mIsReaded)?false:true;
//mIsReaded = !mIsReaded;
saveReadFlag();
refreshUI();
Toast.makeText(getSherlockActivity(),...
In my case commented codeline cause the similar problem (two lines are skipped). For to solve it I just changed this line by codeline posted above (I mean mIsReaded = (mIsReaded)?false:true;) So different cases haves different solutions. It is result of code optimization by compiler, so please refactor something in (inside)
m_cachedPuzzles.removePuzzles(newPuzzles);
I had the same problem. The thing is, you are probably debugging the code that is in your IDE and not the on on the server. You have to deploy the code from the IDE (Eclypse, Netbeans etc.) on the server. It worked for me! Good luck!
Not directly related to Eclipse but I experienced a similar problem using the Xamarin Extension for Visual Studio and my realization may be of some help. I was developing an App with a Class library. when i made changes to the library then began emulating my App, the DLL wouldn't always rebuild so the debugger would step through the PDB as it was before my latest changes. After rebuilding the DLL, it would step through fine.
In short, rebuild dependencies if there are any changes made.
Hope you solve your issue. Have a good one
comment TODO using multi-line comment
/*// TODO this is a bug, now*/
and try again.
I'm a new user of eclipse 3.7 and dont know why eclipse always auto adds "*/" when I didnt notice. So I'm wondering why this happened? I haven't catch when it happens since when I write the same pieces of the code the second time the problem disapears.Can someone tell me how to solve it?
for example,this following really annoys me
public void addBall()
{
try
{
Ball ball = new Ball();
comp.add(ball);
for (int i = 1; i <= STEPS; i++)
{
ball.move(comp.getBounds());
comp.paint(comp.getGraphics());
Thread.sleep(DELAY);
}
}
*/
catch (InterruptedException e)
{
}
}
The problem occurred when I press "{" following the word try. It seems only happens when the corresponding "}" is out of current view, however I'm not really sure.Plus,the compiler didnt give me any warnings.
I'd look at the Java code templates - possibly you triggered something there. The defined templates can be found in Preferences, the Java/Editor/Templates page.
At first look at the try template whether it contains the */; or look for similar patterns as well.
By default, Eclipse automatically adds "*/" when you input "/*" and hit Enter, the same way as it automatically adds closing parenthesis.
I created a method and keep getting an error that I need to include a } at the end of my method. I put the } in and the error is still there! If I then delete that } the same error will pop up on a prior method; and that error wasn't there before. in other words, if i type the } on my most recent method then the error stays there and only there. if i delete it, it duplicates that error on my prior method.
private void putThreeBeepers() {
for (int i = 0; i < 2; i++) {
putBeeper();
move();
}
putBeeper();
}
private void backUp() {
turnAround();
move();
turnAround();
}
You really want to go to the top of your file and do proper and consistent indention all the way to the bottom.
For example...
private void putThreeBeepers()
{
for (int i = 0; i < 2; i++) {
putBeeper();
move();
}
putBeeper();
}
private void backUp()
{
turnAround();
move();
turnAround();
}
Odds are, somewhere along the line, you are missing a }. Your description isn't super clear, but if the code you posted is how you actually have it formatted in your file then odds are you just missed something somewhere... and poor indentation makes it very hard to spot.
The fact that the message is changing is confusing, but it is the sort of thing you see in these cases.
the error might be misleading. In my case i had incorrect/incomplete comment statements such as below which is broken lead to this error:
/*
// */
*/
Fixing the comments fixed the error. Hope this helps. Thanks.
I think this can be caused by a number of different problems. :(
In my case it was that I have forgotten to specify the type of two parameters in one of my methods declareations.
To fix I had to change this:
onUpgrade(SQLiteDatabase pDb, pOldVersion, pNewVersion)
{
}
to this:
onUpgrade(SQLiteDatabase pDb, int pOldVersion, int pNewVersion)
It might be due to invisible Chars when copying code from PDF ebook.
Be careful of the little red dot '.'
Choose 'Select First Character' -> then delete it.
Also, the same error might occur if you accidentally write an if-statement outside of a method. I kept overlooking it since I was looking at the bracket-matching only.
I just simply add another"}",makes as "}}",then problem solved
I didnt have to put anther "}" for my other java code exercise.
Im a java beginner,I've come across same problem so I searched online found this thread.Hope this help
Had the same problem. Turned out to be a very fundamental oversight.
I was having the properties of a class declared like this:
private Texture foo;
private Sprite bar;
foo = new Texture();
bar = new Sprite();
The mistake was i had been instantiating the foo and bar variables outside the functions
of the class. When I put the
foo = new Texture();
bar = new Sprite();
into their proper functions (like below), the error went away.
private Texture foo;
private Sprite bar;
// function
public void instantiateVariables(){
foo = new Texture();
bar = new Sprite();
}
I got this error due to a missing <%.
Here are the steps.
Just copy paste your code in notepad
Remove copy from Java file
Again copy notepad and paste into Java file.
An error will be gone.
This question have already accepted answer but still there are some other problems where it occurs (like even though all statements are there correctly sometimes we will get this issue) and there are solutions too.
Recently I came across like this situation in eclipse workspace.
The solution is
Take the back up of that java file.
Remove the java file from that location and do the build/compile
Paste the file in the same location and do the build/compile
If the above step 3 does not work create new file and paste the content/code from backup file and do the build/compile
If the above step 3&4 both are not working then type the code of that file manually end-to-end and do the build/compile
If this error comes in jsp, look for the braces. if open or close braces are missing, we will get this error.