Try and fail, try, try, try...........fail
Hope success in next try
Ở đâu
Thứ Ba, 17 tháng 12, 2013
Thứ Năm, 12 tháng 12, 2013
Android
MyScene.registerTouchArea(animatedSprite);//Phải đăng ký là cho phép AnimatedSprite này được lắng nghe sự kiện
BitmapTextureAllas dung de bo nho chua anh
- Font
private BitmapTextureAtlas bitmapTextureAtlas;//Lưu ảnh trong bộ nhớ
private TextureRegion textureRegion;//Lưu khi load ảnh
private Sprite sprite;//Sprite quả bóng
BitmapTextureAtlas + Font +Text dung cho Text
BitmapTextureAtlas + Font +ChangeableText dung cho Text
thay doi Text
//Cập nhật (coi như vòn lặp hoạt cảnh)
MyScene.registerUpdateHandler(new IUpdateHandler() {
@Override
public void reset() {
// TODO Auto-generated method stub
}
//Muốn cập nhật cái gì thì cho vào đây
@Override
public void onUpdate(float pSecondsElapsed) {
try {
//Tạm dừng cập nhật trong 1s
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Cập nhật lại những gì bạn cần vẽ lại liên tục
dem++;
textchange.setText(String.valueOf(dem));//Cứ sau 1s ta lại hiện thị đếm
}
});
BitmapTextureAtlas + TextureRegion +Sprite
BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.bitmapTextureAtlas, this, "sprite.png", 0, 0, 2, 1);
this.mEngine.getTextureManager().loadTexture(this.bitmapTextureAtlas);
this.mEngine.registerUpdateHandler(new FPSLogger()); //=====================================LẮNG NGHE SỰ KIỆN CHẠM VÀO MÀN HÌNH MyScene======================================================================
//Bắt sự kiện khi chạm vào MyScene
MyScene.setTouchAreaBindingEnabled(true);//cho phép lắng nghe
MyScene.setOnSceneTouchListener(new IOnSceneTouchListener() {
public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
System.out.println("Sprite onSceneTouchEvent: chạm vào màn hình");
System.out.println("Tọa độ X = "+pSceneTouchEvent.getX());
System.out.println("Tọa độ Y = "+pSceneTouchEvent.getY());
//Khi chạm vào màn hình ta di chuyển AnimatedSprite theo tọ độ y.
animatedSprite.setPosition(animatedSprite.getX(), pSceneTouchEvent.getY());
return true;
}
});
//Check su kien va cham vao sprite
this.mSpirte = new Sprite(100, 100, textRegion){
//lang nghe su kien cham vao sprite
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
float pTouchAreaLocalX, float pTouchAreaLocalY) {
// TODO Auto-generated method stub
if(pSceneTouchEvent.getAction()==TouchEvent.ACTION_DOWN){
System.out.println("Sprite onTouched: Cham vao spirte");
System.out.println("Toa do sprite x: "+pTouchAreaLocalX);
System.out.println("Toa do sprite y: "+pTouchAreaLocalY);
}
return true;
}
};
BitmapTextureAtlas + TitledTextureRegion + AnimatedSprite
BitmapTextureAllas dung de bo nho chua anh
- Font
private BitmapTextureAtlas bitmapTextureAtlas;//Lưu ảnh trong bộ nhớ
private TextureRegion textureRegion;//Lưu khi load ảnh
private Sprite sprite;//Sprite quả bóng
BitmapTextureAtlas + Font +Text dung cho Text
BitmapTextureAtlas + Font +ChangeableText dung cho Text
thay doi Text
//Cập nhật (coi như vòn lặp hoạt cảnh)
MyScene.registerUpdateHandler(new IUpdateHandler() {
@Override
public void reset() {
// TODO Auto-generated method stub
}
//Muốn cập nhật cái gì thì cho vào đây
@Override
public void onUpdate(float pSecondsElapsed) {
try {
//Tạm dừng cập nhật trong 1s
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Cập nhật lại những gì bạn cần vẽ lại liên tục
dem++;
textchange.setText(String.valueOf(dem));//Cứ sau 1s ta lại hiện thị đếm
}
});
BitmapTextureAtlas + TextureRegion +Sprite
BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.bitmapTextureAtlas, this, "sprite.png", 0, 0, 2, 1);
this.mEngine.getTextureManager().loadTexture(this.bitmapTextureAtlas);
this.mEngine.registerUpdateHandler(new FPSLogger()); //=====================================LẮNG NGHE SỰ KIỆN CHẠM VÀO MÀN HÌNH MyScene======================================================================
//Bắt sự kiện khi chạm vào MyScene
MyScene.setTouchAreaBindingEnabled(true);//cho phép lắng nghe
MyScene.setOnSceneTouchListener(new IOnSceneTouchListener() {
public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
System.out.println("Sprite onSceneTouchEvent: chạm vào màn hình");
System.out.println("Tọa độ X = "+pSceneTouchEvent.getX());
System.out.println("Tọa độ Y = "+pSceneTouchEvent.getY());
//Khi chạm vào màn hình ta di chuyển AnimatedSprite theo tọ độ y.
animatedSprite.setPosition(animatedSprite.getX(), pSceneTouchEvent.getY());
return true;
}
});
//Check su kien va cham vao sprite
this.mSpirte = new Sprite(100, 100, textRegion){
//lang nghe su kien cham vao sprite
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
float pTouchAreaLocalX, float pTouchAreaLocalY) {
// TODO Auto-generated method stub
if(pSceneTouchEvent.getAction()==TouchEvent.ACTION_DOWN){
System.out.println("Sprite onTouched: Cham vao spirte");
System.out.println("Toa do sprite x: "+pTouchAreaLocalX);
System.out.println("Toa do sprite y: "+pTouchAreaLocalY);
}
return true;
}
};
BitmapTextureAtlas + TitledTextureRegion + AnimatedSprite
Thứ Bảy, 7 tháng 12, 2013
ngat trang blog
Sử dụng tiện ích "Chèn dấu ngắt nhảy" (một tiện ích có sẵn của Blogspot, sẽ hiển thị khi soạn thảo, chỉnh sửa bài viết) bằng cách nhấp chuột trái vào đoạn văn bản mà bạn muốn cho hiển thị [1] (đoạn văn bản này tính từ dòng đầu tiên trở xuống - xem ảnh minh họa bên dưới), rồi nhấp chuột vào hình tờ giấy bị "rách" [2] trên thanh tác vụ đăng bài.
Thứ Năm, 10 tháng 10, 2013
Chủ Nhật, 8 tháng 9, 2013
Mùi hoa sữa đầu thu
Bắt đầu thu rùi, hnay đã thấy thơm mùi hoa sữa đâu đó, hơn một năm rùi đấy nhỉ...
Thứ Bảy, 23 tháng 2, 2013
Begining with E3roid in Android
Đầu tiên tạo mới 1 project
Step1: copy thư viên E3roid.jar vào thư mục libs trong project, sau đó right click chọn build path->add to build path.
Step2: Sửa lại file Activity chính thay extends Activity la extends từ E3Activity, đồng thời xóa bỏ code khi lúc tạo project tự rend ra.
Step3: Add các hàm overide của class E3Activity, thêm hàm bắt sự kiên touch onTouchEvent nữa
Trong đó: E3engine là để tạo một frame để chứa E3Scene các hình ảnh,
hàm onLoadResource để lấy các hình ảnh vào nhờ texture
- sprite là một hình ảnh tạo ra bằng một texture
-scene.getTopLayer().add(sprite); de them sprite vao scene
Source code:http://www.mediafire.com/?5xjd8gp62ie35r2
Step1: copy thư viên E3roid.jar vào thư mục libs trong project, sau đó right click chọn build path->add to build path.
Step2: Sửa lại file Activity chính thay extends Activity la extends từ E3Activity, đồng thời xóa bỏ code khi lúc tạo project tự rend ra.
Step3: Add các hàm overide của class E3Activity, thêm hàm bắt sự kiên touch onTouchEvent nữa
Trong đó: E3engine là để tạo một frame để chứa E3Scene các hình ảnh,
hàm onLoadResource để lấy các hình ảnh vào nhờ texture
- sprite là một hình ảnh tạo ra bằng một texture
-scene.getTopLayer().add(sprite); de them sprite vao scene
Source code:http://www.mediafire.com/?5xjd8gp62ie35r2
Thứ Sáu, 22 tháng 2, 2013
Đăng ký:
Nhận xét (Atom)

