Insane
logo

Chatbox|Admin nhận làm wap/web, giá cả thương lượng... Thông tin admin tại mỗi bài viết.
Home · Bang hội ·
* Đăng Nhập hoặc Đăng Kí
để sử dụng hết chức năng của diễn đàn.
Hi, Khách!
HomeBang hội » Thủ thuật » Nokia s40 » Share code source j2me tổng hợp
Xuống dưới » Share code source j2me tổng hợp
avatar by Pham_loi Pham_loi
Chức vụ:
09:49:57, 17-07-2015

Viết chương trình soạn tin nhắn bằng J2ME
<?php
package sendsms
;

import java.io.IOException;
import java.io.InterruptedIOException;
import javax.microedition.io.Connector;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.*;
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.TextMessage;

/**
 * @author pc
 */
public class Midlet2 extends MIDlet implements CommandListener {
//phần khởi tạo giao diện
    
private Display display;
    private 
Form form;
    private 
TextField sdt;
    private 
TextField nd;
    private 
Command send, exit;
    private 
Alert alert;
    private 
MessageConnection conn;
//tạo hàm contructor
    
public Midlet2() {
        
display Display.getDisplay(this);
        
form = new Form("mesaging");
        
sdt = new TextField("sđt"""11TextField.PHONENUMBER);
        
nd = new TextField("nội dung tin nhắn"""1000TextField.ANY);
        
send = new Command("Gửi"Command.OK1);
        exit = new 
Command("Thoát"Command.EXIT, 1);
        
form.append(sdt);
        
form.append(nd);
        
form.addCommand(send);
        
form.addCommand(exit);
        
form.setCommandListener(this);
    }

    public 
void startApp() {
        
display.setCurrent(form);
    }

    public 
void pauseApp() {
    }

    public 
void destroyApp(boolean unconditional) {
        
notifyDestroyed();
    }

    public 
void commandAction(Command cDisplayable d) {
        
//bắt sự kiện khi bấm exit
        
if (== exit) {
            
destroyApp(true);
        } else if (
== send) {
            
//tạo biến string xuất chuỗi của 2 textfield
            
String mno sdt.getString();
            
String msg nd.getString();
            if (
mno.equals("")) {
                
//nếu người dùng không nhập gì mà bấm gửi sẽ xuất ra thông báo
                
alert = new Alert("alert""hãy nhập nội dung và số điện thoại"nullAlertType.INFO);
                
alert.setTimeout(alert.FOREVER);
                
display.setCurrent(alert);
            } else {
                try {
                    
//khởi tạo messageconection nếu không gửi được sẽ thông báo lỗi
                    
conn = (MessageConnectionConnector.open("sms://" mno);
                } catch (
Exception ex) {
                    
alert = new Alert("lỗi""không gửi được tin nhắn"nullAlertType.ERROR);
                    
alert.setTimeout(3000);
                    
display.setCurrent(alert);
                }

                try {
                    
//tạo textmessage khi người dùng nhập vào sẽ gửi đi và xuất thông báo gửi thành công
                    
TextMessage tms = (TextMessageconn.newMessage(MessageConnection.TEXT_MESSAGE);
                    
tms.setAddress("sms://" mno);
                    
tms.setPayloadText(msg);
                    
conn.send(tms);
                } catch (
Exception ex) {
                    
alert = new Alert("alert""gửi thành công"nullAlertType.INFO);
                    
alert.setTimeout(alert.FOREVER);
                    
display.setCurrent(alert);
            }
        }
    }
}}
?>

Copy code

Chúc các bạn thành công!


Chỉnh sửa lúc 2016-05-27 00:49 bởi Pham_loi
Like: 0
avatar by Pham_loi Pham_loi
Chức vụ:
00:47:13, 27-05-2016

FileBrowser - Duyệt file trên nền list

. code đơn giản nên thôi giải thích.
<?php
import javax
.microedition.lcdui.*;
import javax.microedition.io.*;
import javax.microedition.io.file.*;

public class 
FileBrowser extends javax.microedition.lcdui.List implements CommandListener {
//Đường dẫn hiện tại
String path="/";
//tạo 2 commmand để nhấn
Command ok=new Command("Ok",Command.OK,1);
Command cancel=new Command("Hủy",Command.CANCEL,2);

     public 
FileBrowser() {
         
super("FileBrowser"javax.microedition.lcdui.List.IMPLICIT);
         
addCommand(ok);
         
addCommand(cancel);
         
setSelectCommand(ok);
         
setCommandListener(this);
         
open();
     }
     
     public 
void commandAction(Command c,Displayable dab){
         if(
c==ok){
             
int select=getSelectedIndex();
             
String t=getString(select);
             if(
path.length()>1){
                 if(
select==0){
                     
//về thư mục trước
                     
path=subpath(path);
                     
refresh();
                 }
                 else {
                     if(
t.endsWith("/")){
                         
path+=t;
                         
refresh();
                     }else{
                         
//file
                     
}
                 }
             }else {
                 
path+=t;
                 
refresh();
             }
         }else if(
c==cancel){
             
//exit chẳng hạn
         
}
     }
     
     public 
void open(){
         
path="/";
         
refresh();
     }
     
     public 
void refresh(){
         try{
             
//xóa tất cả
             
deleteAll();
             
Enumeration mEnum;
             if(
path.length()>1){
                 
FileConnection fc=(FileConnection)Connector.open("file://"+path,1);
                 
mEnum=fc.list();
                 
append(new String("..."),null);
             }
             else 
mEnum=FileSystemRegistry.listRoots();
             while(
mEnum.hasMoreElements())
                 
append((String)mEnum.nextElement(),null);
         }catch(
Exception e){
             if(
path.length()>1){
                 
//lấy lại đường dẫn trước
                 
path=subpath(path);
                 
refresh();
             }else {
                 
open();
             }
         }
     }

     public 
void setPath(String path){
         
this.path=path;
         
refresh();
     }

     public 
String getPath(){
         return 
path;
     }

     public 
String subpath(String p){
         return 
p.substring(0p.substring(0p.length()-1).lastIndexOf('/')+1);
     }
}
?>

Copy code

Like: 0
avatar by Pham_loi Pham_loi
Chức vụ:
01:11:52, 27-05-2016

FireWork-tạo pháo hoa đơn giản trên j2me sử dụng vector

Download FireWork.jar
code gồm 4 file Midlet.java, main.java, manager.java và firework.java.
Trước tiên tạo file chính Midlet.java và để đó sửa sau .
<?php
import javax
.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
 * @author ThanhAn
 */
public class Midlet extends MIDlet {
Display dis;

    public 
void startApp() {
        
dis=Display.getDisplay(this);
    }
    
    public 
void pauseApp() {
    }
    
    public 
void destroyApp(boolean unconditional) {
    }
}
?>

Copy code


Bây giờ tạo class firework, class này có tác dụng vẽ lên màn hình 1 điểm bị ném xiên 1 góc bất bất kì với gia tốc rơi a,vận tốc ném v:
<?php

import javax
.microedition.lcdui.*;
import java.util.*;
/**
 *
 * @author ThanhAn
 */
public class firework {
int w,h,v,x0,x,y,y0,angle,t=0,cl=0xff0000;
/* v-vận tốc bắn 
*  angle-goc bay
*  y0,x0-toa do ban dau
*  cl-mau
*  t-thoi gian
*/
float a;//gia tốc rơi
long last=0l,delay=150l;//thời gian chờ
boolean act=true;
intarr_x=new int[2;
intarr_y=new int[2;

    
    public 
firework(int x0,int y0,int v,int angle,int cl){
        
this.y0=y0;
        
this.x0=x0;
        
this.a=1;//cho gia tốc rơi bằng 1 cho gọn
        
this.v=v;
        
this.angle=angle;
        
//độ rộng màn hình lấy từ class main
        
this.w=main.w;
        
this.h=main.h;
        
this.last=time();
        for(
int i=0;i<2;i++){
            
arr_x[i=x0;
            
arr_y[i=y0;
        }
        
this.cl=cl;
    }

    public 
void preDraw(){
        if(
time()-last>=delay){
            
t++;
            
last=time();
            
/*
            * lấy tọa độ x,y mới
            */
            
arr_x[1=arr_x[0;
            
arr_y[1=arr_y[0;                
            
/*
            * lưu tọa độ x,y trước
            */
            
arr_x[0=x;
            
arr_y[0=y;
            
/* 
            * sử dụng công thức của vật bị ném xiên để tính tọa độ điểm đó lúc sau
            */
            
x=(int)(Math.cos(angle*Math.PI/180)*v*t)+x0;
            
y=(int)(v*Math.sin(angle*Math.PI/180)*t-a*t*t/2)+y0;
        }
    }
    
    public 
void paint(Graphics g){
        
//vẽ điểm đó ra
        
Drawline(g,w-x,h-y,cl);
        
//vẽ thêm 2 điểm cũ và mới của điểm bị ném ban đầu
        
for(int i=0;i<2;i++)
            
Drawline(g,w-arr_x[i,h-arr_y[i,cl);
        
/*
         * do tọa độ đặt trên thiết bị nằm ở góc trái trên cùng
         * vì vậy ta phải đổi hệ tọa độ chuyển về góc phải dưới cùng
         * nên 1 điểm có tọa độ x,y -> chuyển về w-x,h-y
         */
        
if(actpreDraw();
    }
    
    public 
long time(){
        return 
System.currentTimeMillis();//hàm trả về thời gian hiện tại
    
}
    
    public 
void Drawline(Graphics g,int x,int y,int color){
        
g.setColor(color);
        
g.drawLine(xyxy);
    }
}
?>

Copy code


tiếp theo tạo class manager.java quản lý các điểm rơi (firework) cái này giống như nổ tung trên ko :v và bắn ra các phía

<?php
import javax
.microedition.lcdui.*;
import java.util.*;
/**
 *
 * @author ThanhAn
 */

public class manager {
int x,y,goc=1,n=360;
/*
* x,y tọa độ pháo hoa
* goc,n cái này là góc rơi cảu các điểm từ 1->360
*/
//tạo 1 biến random 
Random rd=new Random();
//tạo 1 vector lưu các điểm đó
Vector fw=new Vector();
//màu sắc
intcolor={0xff0000,0xffff00,0x00ff00,0xffffff,0x0000ff,0x00ffff,0xf0f0f0,0xC0C0C0};//mau cho phao hoa
    
    
public manager(int x,int y,int goc,int n){
        
this.x=x;
        
this.y=y;
        
this.goc=goc;
        
this.n=n;
        for(
int i=0;i<n;i++){
           
//thêm các điểm vào vector
           //vận tốc ném cho 3<=v<=11
           
fw.addElement(new firework(x,y,Math.abs(rd.nextInt()%8)+3,i*goc,color[Math.abs(rd.nextInt()%color.length)));
        }
    }
 
   
//vẽ ra màn hình
    
public void paint(Graphics g){
        for(
int i=0;i<fw.size();i++){
            
//lấy đối tượng firework
            
firework f=((firework)(fw.elementAt(i)));
            
//xét xem nằm ngoài màn hình chưa nếu rồi thì xóa nó
            
if(f.x>240||f.x<0||f.y<0||f.y>320fw.removeElementAt(i);
            
//vẽ
            
f.paint(g);
        }
    }
}
?>

Copy code


:)) cuối cung phần quan trọng nhất vẽ tất cả ra màn hình
tạo 1 class mới main.java extends Canvas trong class này ta tạo thêm 1 viên đạn bay từ dưới -> trên sau đó nổ tung

<?php

import javax
.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.util.*;
/**
 *
 * @author ThanhAn
 */

public class main extends Canvas {
Midlet mid;
static 
int w,h;
//tạo 1 đối tượng random
Random r=new Random();
//lưu các class manager
Vector mg=new Vector();
//hình ảnh viên đạn lấy từ game Tankzor
Image img;
//dưới đây là các thuộc tính của viên đạn bay từ dưới -> trên
int f=17,x,y,ag,x0,y0,t,v,ymax=269;
/*
* f=17 frame của ảnh
* ag-goc ban
* x0,y0-toa do ban dau
* t-thoi gian
* v-toc do
* ymax tọa độ y lớn nhất
*/
float a;//gia toc roi tu do
//mang lưu tọa độ của viên đạn bay
intmang_x=new int[3;
intmang_y=new int[3;
//biến xác định xem viên đan đã nổ hay chưa
//nếu nổ rồi ta tiến hành thêm một đối tượng manager rồi vẽ nó
boolean st=false;
long last=0l,delay=150l;
    
    public 
main(Midlet mid){
        
this.mid=mid;
        
setFullScreenMode(true);
        
w=getWidth();
        
h=getHeight();
        try{
            
//ảnh nằm phía dưới
            
img=Image.createImage("/bullets.png");
        }catch(
Exception e){}
    }
 
    public 
void preDraw(){
        
//bat dau di chuyen
        
if(stanimate();
        
//nếu thời gian t>16 thì thêm 1 pháo hoa
        
if(t>16&&st){
             
st=false;
             
mg.addElement(new manager(x,y,1,360));
        }
    }

    public 
void paint(Graphics g){
        
preDraw();
        
g.setColor(0);
        
g.fillRect(00wh);
        
g.setColor(0xff0000);
        
//cái này viết bữa tết nên sẽ để nguyên hehe .
        
g.drawString("Happy New Year!"w/2h/2-12*2Graphics.HCENTER|Graphics.BASELINE);
        
g.drawString("2014"w/2h/2Graphics.HCENTER|Graphics.BASELINE);
        
g.drawString("J2mevn.wapka.mobi"w/2h/2+12*2Graphics.HCENTER|Graphics.BASELINE);
        
//vẽ viên đạn ra
        // tương tự ta cũng đổi hệ tọa độ
        
if(st){
            
g.drawRegion(img19*24024240w-mang_x[2h-mang_y[23);
            
g.drawRegion(img20*24024240w-mang_x[1h-mang_y[13);
            
g.drawRegion(img21*24024240w-mang_x[0h-mang_y[03);
            
g.drawRegion(img22*24024240w-xh-y3);
        }
        
//vẽ pháo hoa ra
        
for(int i=0;i<mg.size();i++)
            ((
manager)(mg.elementAt(i))).paint(g);
        
//trường hợp ko có nhấn phím thì cho pháo hoa tự bắn
        
if(!st)
             
keyPressed(-(Math.abs(r.nextInt()%3)+5));
        
repaint(); 
    }
     
    public 
void keyPressed(int k){
        if(
k==-5&&!st){
            
x0=w/2;
            
ag=80;
            
st=true;
            
add();
        }else
            if(
k==-7&&!st){
            
ag=60;
            
x0=0;
            
st=true;
            
add();
        }
            else if(
k==-6&&!st){
            
ag=120;
            
x0=w;
            
st=true;
            
add();
        }
    }
    
   public 
void add(){
        
y0=0;
        
v=16;
        
t=0;
        
a=1/4;
        for(
int i=0;i<3;i++){
            
mang_y[i=0;
            
mang_x[i=x0;
        }
        
st=true;
    }
   public 
void animate(){
       
mang_y[2=mang_y[1;
       
mang_x[2=mang_x[1;
       
mang_y[1=mang_y[0;
       
mang_x[1=mang_x[0;
       
mang_y[0=y;
       
mang_x[0=x;
       
//chỗ này tương tự như trong file firework mô tả chuyển động của vật bị ném xiên
       
x=(int)(Math.cos(ag*Math.PI/180)*v*t)+x0;
       
y=(int)(v*Math.sin(ag*Math.PI/180)*t-a*t*t/2)+y0;
       if(
time()-last>=delay){
            
t++;
            
last=time();
       }
   }

     public 
long time(){
        return 
System.currentTimeMillis();
    }
}
?>

Copy code


và sửa lại file Midlet như sau :
<?php
import javax
.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
 * @author ThanhAn
 */
public class Midlet extends MIDlet {
Display dis;
main m;

    public 
void startApp() {
        
dis=Display.getDisplay(this);
        
m=new main(this);
        
dis.setCurrent(m);
    }
    
    public 
void pauseApp() {
    }
    
    public 
void destroyApp(boolean unconditional) {
    }
}

?>

Copy code


Đính kèm file ảnh:
Download bullets.png
Nguồn: mbvn

Like: 0
avatar by Pham_loi Pham_loi
Chức vụ:
01:14:49, 27-05-2016

[Project Raining Letters

Font lấy từ project của @Pleasewait, có chỉnh sửa đôi chút
========
App: Raining_Letters.jar
Source: RainingLetters.zip


↓ Tập tin đính kèm ↓


Vui lòng Đăng Nhập để có thể tải file
Raining_Letters.jar
Thể loại: application/jar
Dung lượng: 10.6KB


Vui lòng Đăng Nhập để có thể tải file
RainingLetters.zip
Thể loại: application/zip
Dung lượng: 7.77KB

Like: 0
avatar by Pham_loi Pham_loi
Chức vụ:
01:17:39, 27-05-2016

Game Cờ Caro 3.0

Thi đại học xong rồi nên có thời gian làm tiếp :D
Update tính năng mới version 3.0:
- Mục đánh trước
- Lưu thành tích
hết :3
======
Game: Co_Caro.jar
Source: Caro3.0_src.zip
======
Update 3.1 fix phần thành tích trên màn hình 128x160
Co_Caro.jar


↓ Tập tin đính kèm ↓


Vui lòng Đăng Nhập để có thể tải file
Co_Caro-3.0.jar
Thể loại: application/java-archive
Dung lượng: 33.86KB


Vui lòng Đăng Nhập để có thể tải file
Co_Caro-3.1.jar
Thể loại: application/java-archive
Dung lượng: 33.96KB


Vui lòng Đăng Nhập để có thể tải file
Caro3.0_src.zip
Thể loại: application/zip
Dung lượng: 31KB

Like: 0
avatar by Pham_loi Pham_loi
Chức vụ:
01:33:41, 27-05-2016

Tạo menu lựa chọn game

bài này tôi sẽ hướng dẫn các bạn tạo menu với các lựa chọn trong J2ME

tạo lớp Point.java
<?php
package Zstar
;
 
import javax.microedition.xml.rpc.Operation;
 
/**
*
* @author zstar
*/
public class Point {
 
private 
int X 0;
private 
int Y 0;
 
public 
Point() {
}
 
public 
Point(int xint y) {
this.x;
this.y;
}
 
public 
int getX() {
return 
this.X;
}
 
public 
int getY() {
return 
this.Y;
}
}
?>

Copy code

tạo lớp Menu.java kế thừa từ GameCanvas
<?php
package Zstar
.menu;
 
import Zstar.Point;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
 
/**
*
* @author ZSTAR
*/
 
public class Menu extends GameCanvas {
 
private 
Stringoptions = {"New Game""Map Editor""High Score""About""Exit"};
private 
Point locationMenu = new Point(3030);
private 
int itemWidth;
private 
int item_space 15;
private 
Image itemSelect;
private 
Image itemUnselect;
private 
Graphics g;
private 
int itemHeight;
private 
int currentIndex 0;
private 
int white 0xffffff;
private 
int black 0x000000;
private 
Font font;
 
public 
Menu() {
super(false);
setFullScreenMode(true);
try {
this.this.getGraphics();
itemSelect Image.createImage("/Images/butoption_Press.png");
itemUnselect Image.createImage("/Images/butoption_unPress.png");
this.itemHeight itemSelect.getHeight();
this.itemWidth itemUnselect.getWidth();
this.font Font.getFont(Font.STYLE_ITALICFont.FACE_SYSTEMFont.SIZE_SMALL);
this.locationMenu = new Point(this.getWidth() / this.itemWidth 2this.locationMenu.getY());
g.setFont(font);
} catch (
Exception e) {
};
}
 
public 
void Draw() {
for (
int i 0options.lengthi++) {
if (
currentIndex == i) {
g.drawImage(itemSelectlocationMenu.getX(), locationMenu.getY() + itemHeight item_spaceGraphics.LEFT Graphics.TOP);
 
} else {
g.drawImage(itemUnselectlocationMenu.getX(), locationMenu.getY() + itemHeight item_spaceGraphics.LEFT Graphics.TOP);
}
g.drawString((1) + ". " options[ilocationMenu.getX() + 15locationMenu.getY() + itemHeight item_space 5Graphics.TOP Graphics.LEFT);
this.flushGraphics();
}
}
 
private 
void clear_Item(int i) {
g.setColor(this.white);
g.fillRect(locationMenu.getX(), locationMenu.getY() + itemHeight item_spaceitemWidthitemHeight);
g.drawImage(itemUnselectlocationMenu.getX(), locationMenu.getY() + itemHeight item_spaceGraphics.LEFT Graphics.TOP);
g.setColor(this.black);
g.drawString((1) + ". " options[ilocationMenu.getX() + 15locationMenu.getY() + itemHeight item_space 5Graphics.TOP Graphics.LEFT);
 
flushGraphics();
}
 
private 
void Draw_nextItem(int i) {
clear_Item(i);
g.drawImage(itemSelectlocationMenu.getX(), locationMenu.getY() + itemHeight item_spaceGraphics.LEFT Graphics.TOP);
g.drawString((1) + ". " options[ilocationMenu.getX() + 15locationMenu.getY() + itemHeight item_space 5Graphics.TOP Graphics.LEFT);
flushGraphics();
}
 
public 
void keyPressed(int keyCode) {
switch (
getGameAction(keyCode)) {
case 
UP:
clear_Item(currentIndex);
menuSelectChange(-1);
Draw_nextItem(currentIndex);
break;
case 
DOWN:
clear_Item(currentIndex);
menuSelectChange(1);
Draw_nextItem(currentIndex);
break;
case 
FIRE:
//xu ly khi chon
;
break;
}
}
 
private 
void menuSelectChange(int h) {
//viec lua chon menu se chay vong tron
currentIndex += options.length;
currentIndex currentIndex options.length;
}
}
?>

Copy code

Tạo 1 Midlet để test menu như sau

<?php
package Zstar
;
 
import Zstar.menu.*;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.*;
 
/**
* @author ZSTAR
*/
public class MenuMidlet extends MIDlet {
private 
Menu menu;
 
public 
void startApp() {
menu=new Menu();
menu.Draw();
Display.getDisplay(this).setCurrent(menu);
}
 
public 
void pauseApp() {
}
 
public 
void destroyApp(boolean unconditional) {
}
}
?>

Copy code

kết quả :

img
menu sẽ được chọn khi bấm phím up,down

chúc các bạn vui vẻ

Like: 0
avatar by Pham_loi Pham_loi
Chức vụ:
01:37:02, 27-05-2016

Tạo màn hình load game

bài này tôi sẽ hướng dẫn các bạn tạo màn hình loading game trong J2ME

Từ Netbeans các bạn tạo mới Project J2ME, chọn cấu hình CLDC 1.0 , MIDP 2.0 , chọn device là DefaultcldcMsaPhone1

ta xây dựng 3 lớp Point.java ,LoadingScreen.Java, và Midlet : MainMidlet.java

https://i1.wp.com/nzoqla.bay.livefilestore.com/y1pDN__w9A2oZzcNeFugWN0OSYMc83YYIy2qi9IzazO6O0e5Kngb80RBxdkyv-7RYRc5h80iXOZDZ23t4BoplTSfSQ_2eO3E1pO/j2me2.png

Lớp Point.java
<?php
package Zstar
;
 
/**
*
* @author zstar
*/
public class Point {
 
private 
int X 0;
private 
int Y 0;
 
public 
Point() {
}
 
public 
Point(int xint y) {
this.x;
this.y;
}
 
public 
int getX() {
return 
this.X;
}
 
public 
int getY() {
return 
this.Y;
}
}
?>

Copy code

Lớp LoadingScreen.java
<?php
package Zstar
;
 
import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.GameCanvas;
 
/**
* @author ZSTAR
*/
public class LoadingScreen extends GameCanvas {
 
private 
Graphics g;
private 
String logo "/Images/logo.png";
private 
String text1 "Game tiếng việt trên điện thoại";
private 
String text2 "Đang tải...";
private 
Image imageLogo;
private 
Point root = new Point(3050);
private 
Font fontNormal;
private 
Font fontBold;
//thanh loading
private int colorBorder 0x000000;
private 
int colorLoading 0xcc3301;
private 
int loadingLength 150;
private 
int loadingHeight 5;
private 
int loadingCurrent 0;
private 
int h 10;
private 
MainMidlet mainMidlet;
 
public 
LoadingScreen(MainMidlet main) {
super(false);
this.mainMidlet main;
this.this.getGraphics();
this.fontNormal g.getFont();
this.fontBold Font.getFont(Font.FACE_SYSTEMFont.STYLE_BOLDFont.SIZE_MEDIUM);
setFullScreenMode(true);
try {
imageLogo Image.createImage(logo);
} catch (
IOException ex) {
ex.printStackTrace();
}
this.root = new Point(getWidth() / imageLogo.getWidth() / 2root.getY());
 
}
 
public 
void start() {
clearScreen();
draw();
draw_next_loading();
}
 
public 
void draw() {
g.setColor(0x000000);
g.drawImage(imageLogoroot.getX(), root.getY(), Graphics.TOP Graphics.LEFT);
g.drawString(text1getWidth() / fontNormal.stringWidth(text1) / 2root.getY() + imageLogo.getHeight(), Graphics.TOP Graphics.LEFT);
g.setFont(fontBold);
g.drawString(text2getWidth() / fontBold.stringWidth(text2) / 2root.getY() + imageLogo.getHeight() + 40Graphics.TOP Graphics.LEFT);
g.setFont(fontNormal);
//draw loading
g.setColor(colorBorder);
g.drawRect(getWidth() / loadingLength 2root.getY() + imageLogo.getHeight() + 30loadingLengthloadingHeight);
g.setColor(colorLoading);
g.fillRect(getWidth() / loadingLength 2root.getY() + imageLogo.getHeight() + 30loadingCurrentloadingHeight);
g.setColor(colorBorder);
this.flushGraphics();
}
 
private 
void draw_next_loading() {
clearLoading();
//timer.schedule(task, interval,interval);
for (int i 0loadingLength hi++) {
if (
loadingCurrent loadingLength) {
loadingCurrent += h;
//draw loading
g.setColor(colorBorder);
g.drawRect(getWidth() / loadingLength 2root.getY() + imageLogo.getHeight() + 30loadingLengthloadingHeight);
g.setColor(colorLoading);
g.fillRect(getWidth() / loadingLength 2root.getY() + imageLogo.getHeight() + 30loadingCurrentloadingHeight);
g.setColor(colorBorder);
this.flushGraphics();
try {
Thread.sleep(100);
} catch (
Exception e) {
}
} else {
loadingCurrent 0;
break;
}
}
 
}
 
private 
void clearLoading() {
g.setColor(0xffffff);
g.fillRect(getWidth() / loadingLength 2root.getY() + imageLogo.getHeight() + 30loadingLengthloadingHeight);
this.flushGraphics();
}
 
public 
void clearScreen() {
g.setColor(0xffffff); // white
g.fillRect(00getWidth(), getHeight());
this.flushGraphics();
}
}
?>

Copy code

Lớp MainMidlet.java
các bạn thêm 1 midlet vào source package và code như sau
<?php
package Zstar
;
 
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.*;
 
/**
* @author ZSTAR
*/
public class MainMidlet extends MIDlet {
private 
LoadingScreen loadingScreen;
 
public 
void startApp() {
loadingScreen=new LoadingScreen(this);
Display.getDisplay(this).setCurrent(loadingScreen);
loadingScreen.start();
}
 
public 
void pauseApp() {
}
 
public 
void destroyApp(boolean unconditional) {
}
}
?>

Copy code


Nhấn F6 để chạy ứng dụng ta được kết quả :

img

Like: 0
avatar by Pham_loi Pham_loi
Chức vụ:
01:39:37, 27-05-2016


soft của 1 bạn trong diển đàn nhưng không có code.
Tải xuống MyMidlet.zip (1.0 KB)
Nguồn: wtai.

Like: 0
avatar by Pham_loi Pham_loi
Chức vụ:
01:40:30, 27-05-2016

project hỏi xoáy đáp xoay by NDAK
project build good nhưng so với code hơi chệch 1 tí tí
:hi:
Tải xuống srchoixoaydapxoay.zip (220.63 KB)

Like: 0
avatar by Pham_loi Pham_loi
Chức vụ:
01:41:06, 27-05-2016

Code cài đặt tốc độ và ánh sáng lúc khởi động mọi game

Code này mình viết để chèn vào ninjaschool nhưng nó thật sự chèn đc vào mọi game. Bạn chỉ cần chút thủ đoạn nhỏ để copy bytecode để xử lí 2 class 1chính và class cài speed
img
Source.zip
test.jar

Đã up bản fix tương thích mọi máy ảo kể cả các trình giả lập :*
Caitocdov31fixall.zip

Để dễ hình dung về cách chèn bytecode hay tải cái game đã chèn về vọoc. Be mình không pro nên không biết hướng dẫn thế nào :brick:
Tải xuống Ninja_999v7_Set_Speed_Server.zip (741.35 KB)
Nguồn: wtai

Like: 0
Lên trên  Tổng số: 15
« 1 2 »







Trực Tuyến: Khách: 1
Diễn đàn teen Việt Nam
CopyRight 2014