This site requires JavaScript, please enable it in your browser!
Greenfoot back
Lavenger
Lavenger wrote ...

2018/4/1

Changing worlds

1
2
3
4
Lavenger Lavenger

2018/4/8

#
danpost wrote...
Lavenger wrote...
oh its possible to add 3 && conditions... all along I thought it was only possible to add 2 && conditions
You can combine as many as you want AND'ing (&&) and OR'ing (||) them in any arrangement.
but doesn't && and || check the conditions from left to right so that if the left one isn't true for &&, it will set the Boolean as false and if the left one is true for ||, the will set the Boolean as true
danpost danpost

2018/4/8

#
Lavenger wrote...
but doesn't && and || check the conditions from left to right so that if the left one isn't true for &&, it will set the Boolean as false and if the left one is true for ||, the will set the Boolean as true
AND operations are done before OR operations, barring parenthesis. And, yes, they exhibit short-circuit behavior in that evaluations to the right are only executed if needed. In the prior 3-condition statement , if pip was null (by the first condition), then pip.getWorld() would give a NullPointerException if it were executed (in the second condition).
Lavenger Lavenger

2018/4/8

#
danpost wrote...
Lavenger wrote...
but doesn't && and || check the conditions from left to right so that if the left one isn't true for &&, it will set the Boolean as false and if the left one is true for ||, the will set the Boolean as true
AND operations are done before OR operations, barring parenthesis. And, yes, they exhibit short-circuit behavior in that evaluations to the right are only executed if needed. In the prior 3-condition statement , if pip was null (by the first condition), then pip.getWorld() would give a NullPointerException if it were executed (in the second condition).
ahh I see
Lavenger Lavenger

2018/4/8

#
it seems like wherever pip and minor is stated, it would get an error stating cannot find symbol - variable <<pip/minor>>
danpost danpost

2018/4/8

#
Lavenger wrote...
it seems like wherever pip and minor is stated, it would get an error stating cannot find symbol - variable <<pip/minor>>
It seems I had a problematic "code" tag in an earlier post, here, which caused the code not to show. This is what is should have read:
So, instead of line 23 in your MyWorld class, you would have:
Actor pip;
World minor;
Lavenger Lavenger

2018/4/8

#
danpost wrote...
Lavenger wrote...
it seems like wherever pip and minor is stated, it would get an error stating cannot find symbol - variable <<pip/minor>>
It seems I had a problematic "code" tag in an earlier post, here, which caused the code not to show. This is what is should have read:
So, instead of line 23 in your MyWorld class, you would have:
Actor pip;
World minor;
oh okay
Lavenger Lavenger

2018/4/8

#
why doesn't my minigame run when the pip pops up?
danpost danpost

2018/4/8

#
Lavenger wrote...
why doesn't my minigame run when the pip pops up?
You just need to acivate the PIP simulation. After adding pip into the world, add the following line:
pip.setActiveState(true);
Lavenger Lavenger

2018/4/8

#
oh okay ^^"
Lavenger Lavenger

2018/4/8

#
another problem arises: the .setAciveState is being underlined and it says " cannot find symbol - method setActiveState(Boolean)" what am i missing?
danpost danpost

2018/4/8

#
Lavenger wrote...
another problem arises: the .setAciveState is being underlined and it says " cannot find symbol - method setActiveState(Boolean)" what am i missing?
Alright, with that last addition, the field needs to be of type PIP -- not Actor.
// change this line
Actor pip;
// to this
PIP pip;
Lavenger Lavenger

2018/4/9

#
okay
Lavenger Lavenger

2018/4/9

#
Help... my actors aren't moving when the pip gets added into the world I've tried pressing "w", "a", "s" and "d" (the movement keys) and it doesn't seem to move even after adding in pip.setActiveState(true); when the pip gets added into the main game world, what did I do wrong?
danpost danpost

2018/4/9

#
Lavenger wrote...
my actors aren't moving when the pip gets added into the world I've tried pressing "w", "a", "s" and "d" (the movement keys) and it doesn't seem to move even after adding in pip.setActiveState(true); when the pip gets added into the main game world, what did I do wrong?
You did not show the revised code -- adding it into the world and setting its active state. Inspect the Taihei object and then inspect its actTimer. If its value is 40, then the timer was never started (if everything else was done properly). You could also manually execute the getActiveState method on the PIP object to see if that part was done correctly.
Lavenger Lavenger

2018/4/11

#
it seems like I'm having troubles getting the debugger to show, so I can't see the actTimer value. it says "Thread is running. Threads must be stopped to view details." any idea on how to fix that?
There are more replies on the next page.
1
2
3
4