Try and fail, try, try, try...........fail
Hope success in next try
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.
Đăng ký:
Nhận xét (Atom)
