28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 13 ■ Animating Your Action Figure States: Setting the Image States Based on KeyEvent Processing<br />

Creating ASDW Key Get and Set Methods: NetBeans Insert Code<br />

Place your cursor in front of the closing } curly brace for the InvinciBagel.java class, as shown by the light blue area<br />

in Figure 13-15, and use the Source menu to select the Insert Code option. In the Generate floating menu select the<br />

Getter and Setter option and aKey, dKey, sKey and wKey options, shown in Figure 13-15, so NetBeans will generate<br />

eight .is() and .set() methods, based on this new Boolean declaration statement, also shown at the top of this Figure:<br />

private boolean up, down, left, right, wKey, aKey, sKey, dKey;<br />

The eight method structures NetBeans generates at the end of your class look like the following <strong>Java</strong> code:<br />

public boolean iswKey() {<br />

return wKey;<br />

}<br />

public void setwKey(boolean wKey) {<br />

this.wKey = wKey;<br />

}<br />

public boolean isaKey() {<br />

return aKey;<br />

}<br />

public void setaKey(boolean aKey) {<br />

this.aKey = aKey;<br />

}<br />

public boolean issKey() {<br />

return sKey;<br />

}<br />

public void setsKey(boolean sKey) {<br />

this.sKey = sKey;<br />

}<br />

public boolean isdKey() {<br />

return dKey;<br />

}<br />

public void setdKey(boolean dKey) {<br />

this.dKey = dKey;<br />

}<br />

291

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!