日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

用J2ME在移動設(shè)備上實(shí)現(xiàn)動畫1_JSP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:用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.*;

import javax.microedition.lcdui.*;

// 定義了一個動畫,該動畫其實(shí)只是一系列相同大小的圖片

// 輪流顯示,然后模擬出的動畫

public class AnimatedImage extends TimerTask {;

private Canvas canvas;

private Image[] images;

private int[][] clipList;

private int current;

private int x;

private int y;

private int w;

private int h;

// Construct an animation with no canvas.

public AnimatedImage( Image[] images ){;

this( null, images, null );

};

// Construct an animation with a null clip list.

public AnimatedImage( Canvas canvas, Image[]

images ){; this( canvas, images, null );

};

// Construct an animation. The canvas can be null,

// but if not null then a repaint will be triggered

// on it each time the image changes due to a timer

// event. If a clip list is specified, the image is

// drawn multiple times, each time with a different

// clip rectangle, to simulate transparent parts.

public AnimatedImage( Canvas canvas, Image[] images,

int[][] clipList ){;

this.canvas = canvas;

this.images = images;

this.clipList = clipList;

if( images != null && clipList != null ){;

if( clipList.length < images.length ){;

throw new IllegalArgumentException();

};

};

if( images != null && images.length > 0 ){;

w = images[0].getWidth();

h = images[0].getHeight();

};

};

// Move to the next frame, wrapping if necessary.

public void advance( boolean repaint ){;

if( current >= images.length ){;

current = 0;

};

if( repaint && canvas != null && canvas.isShown()

){;

canvas.repaint( x, y, w, h );

canvas.serviceRepaints();

};

};

// Draw the current image in the animation. If

// no clip list, just a simple copy, otherwise

// set the clipping rectangle accordingly and

// draw the image multiple times.

public void draw( Graphics g ){;

if( w == 0 || h == 0 ) return;

int which = current;

if( clipList == null || clipList[which] == null

){;

g.drawImage( images[which], x, y,

g.TOP | g.LEFT );

}; else {;

int cx = g.getClipX();

int cy = g.getClipY();

int cw = g.getClipWidth();

int ch = g.getClipHeight();

int[] list = clipList[which];

for( int i = 0; i 3 <= list.length; i =

4 ){;

g.setClip( x list[0], y list[1],

list[2], list[3] );

g.drawImage( images[which], x, y,

g.TOP | g.LEFT );

};

g.setClip( cx, cy, cw, ch );

};

};

// Moves the animation's top left corner.

public void move( int x, int y ){;

this.x = x;

this.y = y;

};

// Invoked by the timer. Advances to the next frame

// and causes a repaint if a canvas is specified.

public void run(){;

if( w == 0 || h == 0 ) return;

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ù)模呛茫覀兙拖榷x一個AnimatedImage類:

import java.util.*;

import javax.microedition.lcdui.*;

// 定義了一個動畫,該動畫其實(shí)只是一系列相同大小的圖片

// 輪流顯示,然后模擬出的動畫

public class AnimatedImage extends TimerTask {;

private Canvas canvas;

private Image[] images;

private int[][] clipList;

private int current;

private int x;

private int y;

private int w;

private int h;

// Construct an animation with no canvas.

public AnimatedImage( Image[] images ){;

this( null, images, null );

};

// Construct an animation with a null clip list.

public AnimatedImage( Canvas canvas, Image[]

images ){; this( canvas, images, null );

};

// Construct an animation. The canvas can be null,

// but if not null then a repaint will be triggered

// on it each time the image changes due to a timer

// event. If a clip list is specified, the image is

// drawn multiple times, each time with a different

// clip rectangle, to simulate transparent parts.

public AnimatedImage( Canvas canvas, Image[] images,

int[][] clipList ){;

this.canvas = canvas;

this.images = images;

this.clipList = clipList;

if( images != null && clipList != null ){;

if( clipList.length < images.length ){;

throw new IllegalArgumentException();

};

};

if( images != null && images.length > 0 ){;

w = images[0].getWidth();

h = images[0].getHeight();

};

};

// Move to the next frame, wrapping if necessary.

public void advance( boolean repaint ){;

if( current >= images.length ){;

current = 0;

};

if( repaint && canvas != null && canvas.isShown()

){;

canvas.repaint( x, y, w, h );

canvas.serviceRepaints();

};

};

// Draw the current image in the animation. If

// no clip list, just a simple copy, otherwise

// set the clipping rectangle accordingly and

// draw the image multiple times.

public void draw( Graphics g ){;

if( w == 0 || h == 0 ) return;

int which = current;

if( clipList == null || clipList[which] == null

){;

g.drawImage( images[which], x, y,

g.TOP | g.LEFT );

}; else {;

int cx = g.getClipX();

int cy = g.getClipY();

int cw = g.getClipWidth();

int ch = g.getClipHeight();

int[] list = clipList[which];

for( int i = 0; i 3 <= list.length; i =

4 ){;

g.setClip( x list[0], y list[1],

list[2], list[3] );

g.drawImage( images[which], x, y,

g.TOP | g.LEFT );

};

g.setClip( cx, cy, cw, ch );

};

};

// Moves the animation's top left corner.

public void move( int x, int y ){;

this.x = x;

this.y = y;

};

// Invoked by the timer. Advances to the next frame

// and causes a repaint if a canvas is specified.

public void run(){;

if( w == 0 || h == 0 ) return;

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.*;

import javax.microedition.lcdui.*;

// 定義了一個動畫,該動畫其實(shí)只是一系列相同大小的圖片

// 輪流顯示,然后模擬出的動畫

public class AnimatedImage extends TimerTask {;

private Canvas canvas;

private Image[] images;

private int[][] clipList;

private int current;

private int x;

private int y;

private int w;

private int h;

// Construct an animation with no canvas.

public AnimatedImage( Image[] images ){;

this( null, images, null );

};

// Construct an animation with a null clip list.

public AnimatedImage( Canvas canvas, Image[]

images ){; this( canvas, images, null );

};

// Construct an animation. The canvas can be null,

// but if not null then a repaint will be triggered

// on it each time the image changes due to a timer

// event. If a clip list is specified, the image is

// drawn multiple times, each time with a different

// clip rectangle, to simulate transparent parts.

public AnimatedImage( Canvas canvas, Image[] images,

int[][] clipList ){;

this.canvas = canvas;

this.images = images;

this.clipList = clipList;

if( images != null && clipList != null ){;

if( clipList.length < images.length ){;

throw new IllegalArgumentException();

};

};

if( images != null && images.length > 0 ){;

w = images[0].getWidth();

h = images[0].getHeight();

};

};

// Move to the next frame, wrapping if necessary.

public void advance( boolean repaint ){;

if( current >= images.length ){;

current = 0;

};

if( repaint && canvas != null && canvas.isShown()

){;

canvas.repaint( x, y, w, h );

canvas.serviceRepaints();

};

};

// Draw the current image in the animation. If

// no clip list, just a simple copy, otherwise

// set the clipping rectangle accordingly and

// draw the image multiple times.

public void draw( Graphics g ){;

if( w == 0 || h == 0 ) return;

int which = current;

if( clipList == null || clipList[which] == null

){;

g.drawImage( images[which], x, y,

g.TOP | g.LEFT );

}; else {;

int cx = g.getClipX();

int cy = g.getClipY();

int cw = g.getClipWidth();

int ch = g.getClipHeight();

int[] list = clipList[which];

for( int i = 0; i 3 <= list.length; i =

4 ){;

g.setClip( x list[0], y list[1],

list[2], list[3] );

g.drawImage( images[which], x, y,

g.TOP | g.LEFT );

};

g.setClip( cx, cy, cw, ch );

};

};

// Moves the animation's top left corner.

public void move( int x, int y ){;

this.x = x;

this.y = y;

};

// Invoked by the timer. Advances to the next frame

// and causes a repaint if a canvas is specified.

public void run(){;

if( w == 0 || h == 0 ) return;

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教程/更新時間:2008-08-22
相關(guān)JSP教程