Game Development Reference
In-Depth Information
public void update() {
if(right) { iX += vX }
if(left) { iX -= vX }
if(down) { iY += vY }
if(up) { iY -= vY }
spriteFrame.
setTranslateX
(iX);
spriteFrame.
setTranslateY
(iY);
}
Figure 11-14
.
After the four if statements, add statements calling the .setTranslate() methods off of the spriteFrame
As you can see in
Figure 11-14
, the code is error- and warning-free, and we're
ready to test the code that we have written during the chapter, including a reorganized
InvinciBagel.java class and its six new methods, the updated Bagel.java class and its
.update() method, and the updated GamePlayLoop.java class, and its .handle() method.
Testing Our New Game Design: Moving
InvinciBagel
We have made significant changes to our game application during this chapter, espe-
cially to the structure of the InvinciBagel.java class, adding six all-new methods, and
moving our event handling code around completely. We created an iBagel Bagel ob-