用J2ME在移動設(shè)備上實(shí)現(xiàn)動畫1_JSP教程
推薦:用J2ME與ASP建立數(shù)據(jù)庫連接J2ME是利用HttpConnection建立HTTP連接,然后獲取數(shù)據(jù),ASP也是利用HTTP協(xié)議,因而可以利用J2ME與ASP建立連接,從而訪問數(shù)據(jù)庫。 ASP是MicroSoft公司的服務(wù)器端動態(tài)頁面技術(shù),可以根
使用MIDP(Mobile Information Device Profile)的開發(fā)人員經(jīng)常會抱怨用些什么辦法才可以在一個MIDlet上顯示動畫。 MIDP 1.0 沒有直接提供對動畫的支持(正在開發(fā)中的MIDP 2.0支持),但真要是自己去實(shí)現(xiàn),其實(shí)也并非是一件很難的事。
任何動畫的最基本的前提,是要在足夠快的時間內(nèi)顯示和更換一張張的圖片,讓人的眼睛看到動的畫面效果。圖片必須按照順序畫出來。從一張圖片到下一張圖片之間的變化越小,效果會越好。
首先要做的,是使用你的圖片處理軟件(比如ps或者firework)創(chuàng)建一系列相同大小的圖片來組成動畫。每張圖片代表動畫一幀。需要制作一定數(shù)量的禎--越多的幀會讓你的動畫看上去越平滑。制作好的圖片一定要保存成PNG(Portable Network Graphics)格式,MIDP唯一支持的圖片格式;有兩個辦法讓你剛做好的圖片在MIDlet上變成動畫。第一,把圖片都放到一個web服務(wù)器上,讓MIDlet下載他們,MIDP內(nèi)置的HTTP支持。第二個辦法更簡單,把圖片用MIDlet打包成jar文件。如果你使用的是J2ME開發(fā)工具,把PNG文件放入你的項(xiàng)目文件里面就可以了。
動畫的過程其實(shí)更像帳本記錄:顯示當(dāng)前幀,然后適當(dāng)?shù)馗鼡Q到下一幀。那么使用一個類來完成這個工作應(yīng)該是很恰當(dāng)?shù)�,那好,我們就先定義一個AnimatedImage類:
|
import java.util.*; // Construct an animation with no canvas. public AnimatedImage( Image[] images ){; // Construct an animation with a null clip list. public AnimatedImage( Canvas canvas, Image[] // Construct an animation. The canvas can be null, public AnimatedImage( Canvas canvas, Image[] images, if( images != null && clipList != null ){; if( images != null && images.length > 0 ){; // Move to the next frame, wrapping if necessary. public void advance( boolean repaint ){; if( repaint && canvas != null && canvas.isShown() // Draw the current image in the animation. If public void draw( Graphics g ){; int which = current; if( clipList == null || clipList[which] == null int[] list = clipList[which]; for( int i = 0; i 3 <= list.length; i = g.setClip( cx, cy, cw, ch ); // Moves the animation's top left corner. public void move( int x, int y ){; // Invoked by the timer. Advances to the next frame public void run(){; advance( true ); |
你實(shí)例化一個AnimatedImage對象的時候你必須給AnimatedImage類的構(gòu)造方法傳一個Image對象數(shù)組,該數(shù)組代表動畫的每一幀。
使用MIDP(Mobile Information Device Profile)的開發(fā)人員經(jīng)常會抱怨用些什么辦法才可以在一個MIDlet上顯示動畫。 MIDP 1.0 沒有直接提供對動畫的支持(正在開發(fā)中的MIDP 2.0支持),但真要是自己去實(shí)現(xiàn),其實(shí)也并非是一件很難的事。
任何動畫的最基本的前提,是要在足夠快的時間內(nèi)顯示和更換一張張的圖片,讓人的眼睛看到動的畫面效果。圖片必須按照順序畫出來。從一張圖片到下一張圖片之間的變化越小,效果會越好。
首先要做的,是使用你的圖片處理軟件(比如ps或者firework)創(chuàng)建一系列相同大小的圖片來組成動畫。每張圖片代表動畫一幀。需要制作一定數(shù)量的禎--越多的幀會讓你的動畫看上去越平滑。制作好的圖片一定要保存成PNG(Portable Network Graphics)格式,MIDP唯一支持的圖片格式;有兩個辦法讓你剛做好的圖片在MIDlet上變成動畫。第一,把圖片都放到一個web服務(wù)器上,讓MIDlet下載他們,MIDP內(nèi)置的HTTP支持。第二個辦法更簡單,把圖片用MIDlet打包成jar文件。如果你使用的是J2ME開發(fā)工具,把PNG文件放入你的項(xiàng)目文件里面就可以了。
動畫的過程其實(shí)更像帳本記錄:顯示當(dāng)前幀,然后適當(dāng)?shù)馗鼡Q到下一幀。那么使用一個類來完成這個工作應(yīng)該是很恰當(dāng)?shù)�,那好,我們就先定義一個AnimatedImage類:
|
import java.util.*; // Construct an animation with no canvas. public AnimatedImage( Image[] images ){; // Construct an animation with a null clip list. public AnimatedImage( Canvas canvas, Image[] // Construct an animation. The canvas can be null, public AnimatedImage( Canvas canvas, Image[] images, if( images != null && clipList != null ){; if( images != null && images.length > 0 ){; // Move to the next frame, wrapping if necessary. public void advance( boolean repaint ){; if( repaint && canvas != null && canvas.isShown() // Draw the current image in the animation. If public void draw( Graphics g ){; int which = current; if( clipList == null || clipList[which] == null int[] list = clipList[which]; for( int i = 0; i 3 <= list.length; i = g.setClip( cx, cy, cw, ch ); // Moves the animation's top left corner. public void move( int x, int y ){; // Invoked by the timer. Advances to the next frame public void run(){; advance( true ); |
你實(shí)例化一個AnimatedImage對象的時候你必須給AnimatedImage類的構(gòu)造方法傳一個Image對象數(shù)組,該數(shù)組代表動畫的每一幀。
使用MIDP(Mobile Information Device Profile)的開發(fā)人員經(jīng)常會抱怨用些什么辦法才可以在一個MIDlet上顯示動畫。 MIDP 1.0 沒有直接提供對動畫的支持(正在開發(fā)中的MIDP 2.0支持),但真要是自己去實(shí)現(xiàn),其實(shí)也并非是一件很難的事。
任何動畫的最基本的前提,是要在足夠快的時間內(nèi)顯示和更換一張張的圖片,讓人的眼睛看到動的畫面效果。圖片必須按照順序畫出來。從一張圖片到下一張圖片之間的變化越小,效果會越好。
首先要做的,是使用你的圖片處理軟件(比如ps或者firework)創(chuàng)建一系列相同大小的圖片來組成動畫。每張圖片代表動畫一幀。需要制作一定數(shù)量的禎--越多的幀會讓你的動畫看上去越平滑。制作好的圖片一定要保存成PNG(Portable Network Graphics)格式,MIDP唯一支持的圖片格式;有兩個辦法讓你剛做好的圖片在MIDlet上變成動畫。第一,把圖片都放到一個web服務(wù)器上,讓MIDlet下載他們,MIDP內(nèi)置的HTTP支持。第二個辦法更簡單,把圖片用MIDlet打包成jar文件。如果你使用的是J2ME開發(fā)工具,把PNG文件放入你的項(xiàng)目文件里面就可以了。
動畫的過程其實(shí)更像帳本記錄:顯示當(dāng)前幀,然后適當(dāng)?shù)馗鼡Q到下一幀。那么使用一個類來完成這個工作應(yīng)該是很恰當(dāng)?shù)模呛�,我們就先定義一個AnimatedImage類:
|
import java.util.*; // Construct an animation with no canvas. public AnimatedImage( Image[] images ){; // Construct an animation with a null clip list. public AnimatedImage( Canvas canvas, Image[] // Construct an animation. The canvas can be null, public AnimatedImage( Canvas canvas, Image[] images, if( images != null && clipList != null ){; if( images != null && images.length > 0 ){; // Move to the next frame, wrapping if necessary. public void advance( boolean repaint ){; if( repaint && canvas != null && canvas.isShown() // Draw the current image in the animation. If public void draw( Graphics g ){; int which = current; if( clipList == null || clipList[which] == null int[] list = clipList[which]; for( int i = 0; i 3 <= list.length; i = g.setClip( cx, cy, cw, ch ); // Moves the animation's top left corner. public void move( int x, int y ){; // Invoked by the timer. Advances to the next frame public void run(){; advance( true ); |
你實(shí)例化一個AnimatedImage對象的時候你必須給AnimatedImage類的構(gòu)造方法傳一個Image對象數(shù)組,該數(shù)組代表動畫的每一幀。
分享:使用OTA來發(fā)布J2ME程序眾所周知,J2ME程序發(fā)布的形式主要有:OTA、數(shù)據(jù)線傳輸、紅外和藍(lán)牙傳輸?shù)取_@里簡單說說如何通過OTA來發(fā)布你的程序。OTA是Over The Air的簡寫,也就是通過網(wǎng)絡(luò)下載,這是主要的發(fā)布
- jsp response.sendRedirect不跳轉(zhuǎn)的原因分析及解決
- JSP指令元素(page指令/include指令/taglib指令)復(fù)習(xí)整理
- JSP腳本元素和注釋復(fù)習(xí)總結(jié)示例
- JSP FusionCharts Free顯示圖表 具體實(shí)現(xiàn)
- 網(wǎng)頁模板:關(guān)于jsp頁面使用jstl的異常分析
- JSP頁面中文傳遞參數(shù)使用escape編碼
- 基于jsp:included的使用與jsp:param亂碼的解決方法
- Java Web項(xiàng)目中連接Access數(shù)據(jù)庫的配置方法
- JDBC連接Access數(shù)據(jù)庫的幾種方式介紹
- 網(wǎng)站圖片路徑的問題:絕對路徑/虛擬路徑
- (jsp/html)網(wǎng)頁上嵌入播放器(常用播放器代碼整理)
- jsp下顯示中文文件名及絕對路徑下的圖片解決方法
- 相關(guān)鏈接:
- 教程說明:
JSP教程-用J2ME在移動設(shè)備上實(shí)現(xiàn)動畫1
。