📄 151-152.html
字号:
<HTML>
<HEAD>
<META name=vsisbn content="1571690433"><META name=vstitle content="Black Art of Java Game Programming"><META name=vsauthor content="Joel Fan"><META name=vsimprint content="Sams"><META name=vspublisher content="Macmillan Computer Publishing"><META name=vspubdate content="11/01/96"><META name=vscategory content="Web and Software Development: Programming, Scripting, and Markup Languages: Java"><TITLE>Black Art of Java Game Programming:Adding Interactivity</TITLE>
<!-- HEADER --><STYLE type="text/css"> <!-- A:hover { color : Red; } --></STYLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><script><!--function displayWindow(url, width, height) { var Win = window.open(url,"displayWindow",'width=' + width +',height=' + height + ',resizable=1,scrollbars=yes'); if (Win) { Win.focus(); }}//--></script><SCRIPT><!--function popUp(url) { var Win = window.open(url,"displayWindow",'width=400,height=300,resizable=1,scrollbars=yes'); if (Win) { Win.focus(); }}//--></SCRIPT><script language="JavaScript1.2"><!--function checkForQuery(fm) { /* get the query value */ var i = escape(fm.query.value); if (i == "") { alert('Please enter a search word or phrase'); return false; } /* query is blank, dont run the .jsp file */ else return true; /* execute the .jsp file */}//--></script></HEAD><BODY>
<TABLE border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=75 valign=top>
<img src="../1571690433.gif" width=60 height=73 alt="Black Art of Java Game Programming" border="1">
</td>
<td align="left">
<font face="arial, helvetica" size="-1" color="#336633"><b>Black Art of Java Game Programming</b></font>
<br>
<font face="arial, helvetica" size="-1"><i>by Joel Fan</i>
<br>
Sams, Macmillan Computer Publishing
<br>
<b>ISBN:</b> 1571690433<b> Pub Date:</b> 11/01/96</font>
</td>
</tr>
</table>
<P>
<!--ISBN=1571690433//-->
<!--TITLE=Black Art of Java Game Programming//-->
<!--AUTHOR=Joel Fan//-->
<!--AUTHOR=Eric Ries//-->
<!--AUTHOR=Calin Tenitchi//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=4//-->
<!--PAGES=151-152//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="146-151.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch05/153-161.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading22"></A><FONT COLOR="#000077">Suggestion Box</FONT></H3>
<DL>
<DD><B>•</B> Create TextSprite by wrapping the String and Font in a Sprite subclass. Then, you can define a TextLoop sprite, which flashes a sequence of messages, by modeling it from BitmapLoop.
<DD><B>•</B> Here are some options you can add to BitmapLoop. Randomly specify how long each particular bitmap should be displayed. This way, you can show certain bitmaps for varying amounts of time to create jerky motions. Also, write the methods addImage() and deleteImage(), which permit you to add and remove images from the loop dynamically. One way of doing this is to allocate a new array of the appropriate size, and use System.arraycopy() to copy the desired elements.
<DD><B>•</B> Create new behaviors for the UFO by defining different sprites that are restored or suspended depending on user input. For example, when you press an arrow key, display a BitmapLoop that animates UFO thrusters. Another example is a shield, which you can define as an OvalSprite that overlays the UFO sprite.
</DL>
<H3><A NAME="Heading23"></A><FONT COLOR="#000077">Summary</FONT></H3>
<P>In this chapter, you have learned the intricacies of handling mouse and keyboard events in applets, which you will use in all future games. In addition, you have seen how to display text in an applet, which is necessary to relay information to the player. Another important thing that you have learned is the use of MediaTracker to load images synchronously. Finally, you have learned to create BitmapLoop sprites, which are sprites that are little animations in themselves.
</P>
<P>Now you are ready for your first Java video game!</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="146-151.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch05/153-161.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -