|
Hi,
I have recently read a book by David Brackeen called 'Developing Games in Java'. I understand the code in the book and am currently modifying the game engine however; I have come across a problem whilst trying to create the player inventory.
I am using code in beanshell scripts to update objects in the game and looking through different scripts by David Brackeen I came across this code, ’player.getInventory().setRedKey(true);’. I understand it means ‘if the player object’s inventory does not have the red key after a red key collision, add the key to the inventory’.
My question is how would I write this code into my netbeans IDE (so it is recognised in the script) as nesting the ‘setRedKey(Boolean)’ brings up errors when I put it in the ‘getInventory()’ helper method of my GameObject class.
|
|
|
|
|
kurt1 wrote: setRedKey(Boolean)’ brings up errors We have no idea what this method, or even its containing class, is supposed to do, so it is impossible to make any suggestions. Also, if you get errors then provide the exact text of the messages and the lines of code that cause them.
|
|
|
|
|
Thank you Richard. I had numerous errors but the main being a reflection error stating that .setRedKey(true) could not be found in my .bsh script (however it was there).
I think i have fixed the problem by removing 'player.getInventory()' and just using the method 'redKey.setCollected(true)', this puts the redKey object into an arrayList which i can then use as the players inventory to be shown on the screen when the player presses the 'i' key.
Kurt.
|
|
|
|