home

2014년 8월 27일 수요일

가상 CD 마운트 프로그램 WinCDEmu, 데몬툴즈 대체용

가상 CD 마운트 프로그램 - 데몬툴즈 대체용

데몬툴즈가 좀 이상해졌더군요...


WinCDEmu

http://wincdemu.sysprogs.org/download/

Autocad 64bit keygen

http://windowsforum.kr/qna/3655226

[AndEngine] 메모리 관리 및 팁

1. 스프라이트.detachSelf() 를 많이 씀.

Vector<Sprite> S = new Vector<Sprite>();

Sprite sprite;
sprite = (new Sprite(10+S.size()*1, 10+S.size()*1, texture, this.getVertexBufferObjectManager()));
S.add(sprite);

2. 저장해놓고 벡터객체를 지움.
remove_all() {
    Sprite sprite = null;
    while (S.size() : 0) {
        sprite = S.remove(0);
        sprite.detachSelf();
        sprite.dispose();
    }
    done = false;
}

3. Nullpointer in onResume에러가 발생한다면
AndroidMenifest.xml 에서 screenSize

<activity
     androd:name="test.tt.hahaah_Apple_name"
     android:configChanges = orientation|screenSize">

os설치용 usb를 간단히 만드는 유틸 - rufus 1.4.7

rufus 1.4.7

https://docs.google.com/file/d/0BxXlDpzEfAqwZm1GMnl2eVZGOGc/edit

2014년 8월 22일 금요일

[AndEngine] 14. Box2D

1. world 선언
private PhysicsWorld mPhysicsWorld;
this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);

2. body(강체) 선언
final Body body;

3. FIXTURE_DEF의 선언 (밀도, 탄성, 마찰력)
private static final FixtureDef FIXTURE_DEF = PhysicsFactory.createFixtureDef(1, 0.5f, 0.5f)

4. 충돌 도형 선언
body = PhysicsFactory.createBoxBody(this.mPhysicsWorld, face, BodyType.DynamicBody, FIXTURE_DEF);

5. 모양과 바디 연결
this.mScene.attachChild(face);
this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(face, body, true, true));


참고) 4번에 선언된 바디 종류
- 정적바디(StaticBody) : 위치가 고정된 바디, 충돌해도 위치 안 바뀜.
- 키네마틱 바디(Kinematic Body) : 위치 고정이지만 속도 방향을 지정해 이동 가능
- 동적 바디(Dynamic Body) : 동적객체, 이동 및 회전 가능

[AndEngine] 13. 마켓에 등록할 apk만들기.

1. 이클립스 -> AndroidMenifest.xml ->  Manifest탭 선택 -> Use the Export Wizard 선택
2. Apk선택
3. keystore 생성 및 선택, 부가정보 입력
   Validity는 서명이 유효한 기간이므로 50년쯤? 입력
4. 구글 크롬을 이용해서 "구글 콘솔"에 등록

[AndEngine] 12. 해상도

1. 기본은 1280 720 으로 개발 layout-hdpi

2. 1280 800도 함께 테스트...하다가 안되면
layout-xhdpi-1280x800 해상도 추가

3. 마지막 800x480 에서 문제가 생긴다면
layout-xdhpi는 1280x720 용으로 빼서 분리하고
layout-hdpi는 800x480용으로 개발


안드로이드 기본 아이콘은 72x72
xhdpi용 아이콘은 96x96으로 만들어서 drawable-xhdpi폴더에 넣어주세요.


2014년 8월 15일 금요일

[AndEngine] 11. Intro Screen

1. activity하나 만듬.
2. nullpointerexception 방지를 위해 manifest에 추가.
    android:configChanges="orientation|screenSize"
3.
public class Intro extends Activity {
    Intent intent = null;

    @Override
    onCreate {
        System.gc();
        ....
        Handler x = new Handler();
        x.postDelayed(new splashHandler(), 1000);
    }

    public class splashHandler implements Runnable {
        public void run() {
            Intent intent = new Intent(getApplicationContext(),
                         Jump.class);
            startActivity(intent);

            finish();
        }
    }

    private void clearApplicationCache(java.io.File dir) {
        if (dir == null)
            dir = getCacheDir();
        else
            ;

        if (dir == null)
            return;
     
        java.io.File[] children = dir.listFiles();
        try {
            for (int i=0; i < children.length; i++)
                if (children[i].isDirectory())
                    clearApplicationCache(children[i]);
                else
                    children[i].delete();
        } catch (Exception e) {
        }
    }

    @Override
    public void onDestory() {
        super.onDestory();
        clearApplicationCache(null);
    }
}

[AndEngine] 10. Font 폰트

1. set font.

private Font mFont1;
private Font mFont2;

onCreateResources() {
    ....
    this.mFont1 = FontFactory.create(this.getFontManager(),
            this.getTextureManager(), 256, 256, Typeface.create(Typeface.DEFAULT, Typeface.BOLD, 32);
    this.mFont1.load();

    FontFactory.setAssetBasePath("font/");
    this.mFont2 = FontFactory.create(this.getFontManager(),
            this.getTextureManager(), 512, 512, Typeface.create(Typeface.BILINEAR, this.getAssets(), "Droid.ttf", 28, true, Color.WHITE);
    this.mFont2.load();
    ....
}

onCreateScene() {
    ...
    text = new Text(80, y, this.mFont1, content, content.length(), vertexBufferObjectManager);
}


2. display point.
//
leftText = new Text(80, 35, this.mFont, "0 Meter", "XXXX Meter".length(), vertexBufferObjectManager);
leftText.registerEntityModifier(new ScaleModifier(2, 0.0f, 1.0f));
scene.attachChild(leftText);

[AndEngine] 9. Collision 충돌


if (obj1.collidesWith(obj2) {

}

scene.registerUpdateHandler(new IUpdateHandler() {
    @Override
    public void reset() {
    }

    @Override
    public void onUpdate(final float pSecondsElapsed) {
        if (stone.collidesWith(jump) {
            //TODO
        }
    }
}

[AndEngine] 8. Animation

1. move

onCreateResources() {
    ....
    this.mBitmapTextureAtlasJump = new BitmapTextureAtlas(
            this.getTextureManger(), 200, 100, TextureOptions.BILINEAR);  //image 200x100
    this.mFaceTextureRegionJump = BitmapTextureAtlasTextureRegionFactory.createTitledFromAsset(this.mBitmapTextureAtlasJump, this, "jump.gif", 0, 0, 2, 1);  //2 images
   
    this.mBitmapTextureAtlasJump.load();
}

onCreateScene() {
    ....
    //animate(long[] pFrameDurations, int pFirstTileIndex, int pLastTileIndex, boolean pLoop)
    jump.animate(new long[] {400, 400}, 0, 1, true);
    scene.attachChild(jump);

    return scene;
}
   

2. rotate
//(float pDuration, float pFromRotation, float pToRotation)
this.registerEntityModifier(new RotationModifier(1, 0, -360));


[AndEngine] 7. Jump

onCreateScene() {
    ....
    final Jump jump = new Jump(center_X, center_Y, this.mFaceTextureRegionJump, this.getVertexBufferObjectManager());
    scene.attachChild(jump);

    return scene;
}

private static class Jump extends AnimatedSprite {
    private final PhysicsHandler mPhysicsHandler;

    public Jump(final float pX, final float pY, final TiledTextureRegion pTextureRegion, final VertexBufferObjectManger pVertexBufferObjectManager) {
        super(pX, pY, pTextureRegion, pVertexBufferObjectManager);
        this.mPhysicsHandler = new PhysicsHandler(this);
       
        this.mPhysicsHandler.setVelocityY(JumpSample.DEMO_VELOCITY);
    }
    @Override
    protected void onManagedUpdate(final float pSecondsElapsed) {
        ....
        this.mPhysicsHandler.setVelocityY(JumpSample.DEMO_VELOCITY);//+
        this.mPhysicsHandler.setVelocityY(-JumpSample.DEMO_VELOCITY);//-
    }
}

[AndEngine] 6. scroll image.

onCreateResources() {
    this.mAutoParallaxBackgroundTexture = new BitmapTextureAtlas(
            this.getTextureManager(), 800, 480);
...
}

onCreateScene() {
    ....
    final AutoParallaxBackground autoParallaxBackground = 
            new AutoParallaxBackround(0, 0, 0, 5);
    final VertexBufferObjectManager vertexBufferObjectManager = 
            this.getVertexBufferObjectManager();

    final ParallaxEntity bEntity = new ParallaxEntity(+2.0f,
            new Sprite(0, CAMERA_HEIGHT - this.mParallaxLayerBack.getHeight(),
            this.mParallaxLayerBack, vertexBufferObjectManager));
    autoParallaxBackground.attachParallaxEntity(bEntity);
    scene.setBackground(autoParallaxBackground);

    return scene;
}

[AndEngine] 5. Sound

ogg를 사용한다.

1. ogg converter
Free Audio Converter

2. sound editor
Shuangs Audio Editor

3. free sound source
http://www.freesound.org

4. edit source

onCreateEngineOptions() {
    ....
    engineOptions.getAudioOptions().setNeedsMusic(true);
   
    return engineOptions;
}
onCreateResource() {
    ....
    MusicFactory.setAssetBasePath("mfx/");
    try {
        this.mMusic = MusicFactory.createMusicFromAsset(
            this.mEngine.getMusicManager(), this, "music.ogg");
        this.mMusic.setLooping(true);
    } catch (final IOException e) {
        Debug.e(e);
    }
}
onCreateScene() {
    ....
    [project class name].this.mMusic.play();
    return scene;
}

[AndEngine] 4. time delay

public void closeAll() {
    scene.registerUpdateHandler(new TimerHandler(0.2f, new ITimerCallback() {
        @Override
        public void onTimePassed(final TimerHandler pTimerHandler) {
            scene.unregisterUpdateHandler(pTimerHandler);
        }
}));

2014년 8월 14일 목요일

[AndEngine] 3. Touch Event


@Override
protected Scene onCreateScene() {
    scene = new Scene();
    scene.setBackground(new Background(0.f, 0.f, 0.f));
    final VertextBufferObjectManager vertexBufferObjectManager
        = this.getVertexBufferObjectManager();

    appleSprite = new Sprite(10, 130, this.mImgObjBehind, vertexBufferObjectManager);
    backSprite = new Sprite(10, 130, this.mImgObj, vertexBufferObjectManager);

    scene.attchChild(bakSprite);
    scene.setOnScreenTouchListener(this);
 
    return scene;
}

@Override
public boolean onScreenTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
    if(pSceneTouchEvent.isActionDown() {
        scene.detachChild(backSprite);
        scene.attachChild(appleSprite);
        return true;
    }
    return false;
}

[AndEngine] 2. 이미지 그리기

이미지를 넣고 그려보자

1. 작업중인 프로젝트의 root폴더에 assets폴더를 만들자. src, bin, res등과 같은 레벨
2. assets폴더안에 font, gfx (이미지를 넣을), mfx(sound를 넣을)폴더를 만들자
그럼 아래와 비슷한 구조가 된다.
src
bin
assets
    font
    gfx
    mfx
res
3. 그림판에서 작은 이미지를 하나 만들어서 gfx폴더에 넣는다. png, gif, jpeg아무거나 상관없다함.
4. image를 gfx폴더에 넣는다
5. 소스를 수정한다.

                   private BitmapTextureAtlas mBgTexture;
                   private ITextureRegion mImgObj;

                   @Override
                   public EngineOptions onCreateEngineOptions() {
                       camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
                       EngineOptions engineOptions = new EngineOptions(true,
                            ScreenOrientation.PORTRAIT_FIXED, new FillResolutionPolicy(), camera();
                       return engineOptions;
                   }
           @Override  //이미지, 사운드 파일 정의 및 선언.
           protected void onCreateResources() {
                       BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
                       this.mBgTexture = new BitmapTextureAtlas(
                               this.getTextureManager(), CAMERA_WIDTH, CAMERA_HEIGHT);
                       this.mImgObj = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBgTexture, this, "back.png", 0, 0);
                       this.mBgTextrue.load();
}
           @Override  // 실제 게임 동작구현부분
           protected Scene onCreateScene() {
               Scene scene = new Scene();
                       scene.setBackground(new Background(0f, 0f, 0f);//black
 
                       final VertextBufferObjectManager vertexBufferObjectManager
                           = this.getVertexBufferObjectManager();
                       scene.attachChild(new Sprite(10, 130, this.mImgObj, vertexBufferObjectManager));
                       return scene;
           }

[AndEngine] 1. 기본 세팅

먼저 이 내용은 "만들면서 배우는 AndEngine게임 프로그래밍, 최원효 지음, 한빛미디어"
책을 보면서 요약한 내용임을 밝힙니다.
예제 : http://www.hanb.co.kr/exam/2058

Android 4.2.2기준.

1. ADT설치(http://dev.android.com -> developer -> tools), jdk설치
2. ADT실행하여 import -> git -> uri 해서 AndEngine소스를 받음
   https://github.com/nicolasgramlich/AndEngine.git
3. AndEngine프로젝트의 Android버전을 정해주고 에러가 없는지 확인
4. Android 프로젝트를 새로 생성함.
5. 새로만든 프로젝트에서 마우스 오른쪽 눌러 메뉴에서 properties -> Android 탭 -> 하단에 Library에 AndEngine추가
6. 자동으로 만들어진 MainActivity.java를 수정함
        public class MainActivity extends SimpleBaseGameActivity {
           @Override  //카메라 동작방식, 화면 가로/세로 지정, 사운드 설정
           public EngineOptions onCreateEngineOptions() {
               return null;
           }
           @Override  //이미지, 사운드 파일 정의 및 선언.
           protected void onCreateResources() {}
           @Override  // 실제 게임 동작구현부분
           protected Scene onCreateScene() {
               return null;
           }
       }
7. 빌드.
8. 에뮬레이터에서 에러가 난다면 AVD옵션중에 Use Host GPU를 활성화한다.
그냥 폰으로 테스트 해도 괜찮을듯.