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

2013/5/12

coding problem

1
2
Banginwithflavor Banginwithflavor

2013/5/12

#
oh and its in the class "player"
Banginwithflavor Banginwithflavor

2013/5/12

#
Ive added a copy of my project if that helps. My coding isnt the neatest. https://www.dropbox.com/sh/kdn0bguc6hoit4g/SEBcDzIMw0
danpost danpost

2013/5/12

#
First, place the method in the target class and add an act method to that class:
public void act()
{
    checkTarget();
}
The method should probably be named more appropriately (something like 'checkActivation'). Also, the 'Target' class was not name very well, either (very mis-leading). It should be something like 'Gun' or 'Cannon' or 'Emitter').
danpost danpost

2013/5/12

#
Can't you upload the project on the site?
Banginwithflavor Banginwithflavor

2013/5/12

#
haha thanks ill change that. I need to make my code neater so others can read it !
Banginwithflavor Banginwithflavor

2013/5/12

#
hmmm didnt think of that. Where is the upload button?
danpost danpost

2013/5/12

#
Near the upper-right corner of the scenario frame, you will see a 'Share' button which will bring up a new dialog. Select the 'Publish' tab (it probably is already selected); enter the name of the project; check the 'Publish source code' checkbox; enter your username and password; and, click the 'Share' button.
Banginwithflavor Banginwithflavor

2013/5/12

#
done.
danpost danpost

2013/5/12

#
I see one problem immediately. Neither barrel nor target should be sub-classes of player (they both should 'extend Actor'). Move the methods related to the angle of the barrel from the player class to the barrel class. Move the 'checkTarget' method from the player class to the target class and call it from the act method, there.
You need to login to post a reply.
1
2