用J2ME在移動設備上實現動畫1_JSP教程
推薦:用J2ME與ASP建立數據庫連接J2ME是利用HttpConnection建立HTTP連接,然后獲取數據,ASP也是利用HTTP協議,因而可以利用J2ME與ASP建立連接,從而訪問數據庫。 ASP是MicroSoft公司的服務器端動態頁面技術,可以根
使用MIDP(Mobile Information Device Profile)的開發人員經常會抱怨用些什么辦法才可以在一個MIDlet上顯示動畫。 MIDP 1.0 沒有直接提供對動畫的支持(正在開發中的MIDP 2.0支持),但真要是自己去實現,其實也并非是一件很難的事。
任何動畫的最基本的前提,是要在足夠快的時間內顯示和更換一張張的圖片,讓人的眼睛看到動的畫面效果。圖片必須按照順序畫出來。從一張圖片到下一張圖片之間的變化越小,效果會越好。
首先要做的,是使用你的圖片處理軟件(比如ps或者firework)創建一系列相同大小的圖片來組成動畫。每張圖片代表動畫一幀。需要制作一定數量的禎--越多的幀會讓你的動畫看上去越平滑。制作好的圖片一定要保存成PNG(Portable Network Graphics)格式,MIDP唯一支持的圖片格式;有兩個辦法讓你剛做好的圖片在MIDlet上變成動畫。第一,把圖片都放到一個web服務器上,讓MIDlet下載他們,MIDP內置的HTTP支持。第二個辦法更簡單,把圖片用MIDlet打包成jar文件。如果你使用的是J2ME開發工具,把PNG文件放入你的項目文件里面就可以了。
動畫的過程其實更像帳本記錄:顯示當前幀,然后適當地更換到下一幀。那么使用一個類來完成這個工作應該是很恰當的,那好,我們就先定義一個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 ); |
你實例化一個AnimatedImage對象的時候你必須給AnimatedImage類的構造方法傳一個Image對象數組,該數組代表動畫的每一幀。
使用MIDP(Mobile Information Device Profile)的開發人員經常會抱怨用些什么辦法才可以在一個MIDlet上顯示動畫。 MIDP 1.0 沒有直接提供對動畫的支持(正在開發中的MIDP 2.0支持),但真要是自己去實現,其實也并非是一件很難的事。
任何動畫的最基本的前提,是要在足夠快的時間內顯示和更換一張張的圖片,讓人的眼睛看到動的畫面效果。圖片必須按照順序畫出來。從一張圖片到下一張圖片之間的變化越小,效果會越好。
首先要做的,是使用你的圖片處理軟件(比如ps或者firework)創建一系列相同大小的圖片來組成動畫。每張圖片代表動畫一幀。需要制作一定數量的禎--越多的幀會讓你的動畫看上去越平滑。制作好的圖片一定要保存成PNG(Portable Network Graphics)格式,MIDP唯一支持的圖片格式;有兩個辦法讓你剛做好的圖片在MIDlet上變成動畫。第一,把圖片都放到一個web服務器上,讓MIDlet下載他們,MIDP內置的HTTP支持。第二個辦法更簡單,把圖片用MIDlet打包成jar文件。如果你使用的是J2ME開發工具,把PNG文件放入你的項目文件里面就可以了。
動畫的過程其實更像帳本記錄:顯示當前幀,然后適當地更換到下一幀。那么使用一個類來完成這個工作應該是很恰當的,那好,我們就先定義一個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 ); |
你實例化一個AnimatedImage對象的時候你必須給AnimatedImage類的構造方法傳一個Image對象數組,該數組代表動畫的每一幀。
使用MIDP(Mobile Information Device Profile)的開發人員經常會抱怨用些什么辦法才可以在一個MIDlet上顯示動畫。 MIDP 1.0 沒有直接提供對動畫的支持(正在開發中的MIDP 2.0支持),但真要是自己去實現,其實也并非是一件很難的事。
任何動畫的最基本的前提,是要在足夠快的時間內顯示和更換一張張的圖片,讓人的眼睛看到動的畫面效果。圖片必須按照順序畫出來。從一張圖片到下一張圖片之間的變化越小,效果會越好。
首先要做的,是使用你的圖片處理軟件(比如ps或者firework)創建一系列相同大小的圖片來組成動畫。每張圖片代表動畫一幀。需要制作一定數量的禎--越多的幀會讓你的動畫看上去越平滑。制作好的圖片一定要保存成PNG(Portable Network Graphics)格式,MIDP唯一支持的圖片格式;有兩個辦法讓你剛做好的圖片在MIDlet上變成動畫。第一,把圖片都放到一個web服務器上,讓MIDlet下載他們,MIDP內置的HTTP支持。第二個辦法更簡單,把圖片用MIDlet打包成jar文件。如果你使用的是J2ME開發工具,把PNG文件放入你的項目文件里面就可以了。
動畫的過程其實更像帳本記錄:顯示當前幀,然后適當地更換到下一幀。那么使用一個類來完成這個工作應該是很恰當的,那好,我們就先定義一個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 ); |
你實例化一個AnimatedImage對象的時候你必須給AnimatedImage類的構造方法傳一個Image對象數組,該數組代表動畫的每一幀。
分享:使用OTA來發布J2ME程序眾所周知,J2ME程序發布的形式主要有:OTA、數據線傳輸、紅外和藍牙傳輸等。這里簡單說說如何通過OTA來發布你的程序。OTA是Over The Air的簡寫,也就是通過網絡下載,這是主要的發布
- jsp response.sendRedirect不跳轉的原因分析及解決
- JSP指令元素(page指令/include指令/taglib指令)復習整理
- JSP腳本元素和注釋復習總結示例
- JSP FusionCharts Free顯示圖表 具體實現
- 網頁模板:關于jsp頁面使用jstl的異常分析
- JSP頁面中文傳遞參數使用escape編碼
- 基于jsp:included的使用與jsp:param亂碼的解決方法
- Java Web項目中連接Access數據庫的配置方法
- JDBC連接Access數據庫的幾種方式介紹
- 網站圖片路徑的問題:絕對路徑/虛擬路徑
- (jsp/html)網頁上嵌入播放器(常用播放器代碼整理)
- jsp下顯示中文文件名及絕對路徑下的圖片解決方法
- 相關鏈接:
- 教程說明:
JSP教程-用J2ME在移動設備上實現動畫1
。