tag:blogger.com,1999:blog-73622381883442436792024-02-21T02:41:03.800-08:00Android StoryJun's Papahttp://www.blogger.com/profile/05988238413662497858noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-7362238188344243679.post-6587995836508853582011-05-12T07:47:00.000-07:002011-05-13T13:35:01.032-07:00Xcode 4<a href="http://mfiles.naver.net/a530b90a102e2f9fb752340638d5a6db7d2ad3ef/20110512_21_blogfile/herossg_1305211094659_5K4424_torrent/xcode_4_final.6233989.tpb.torrent?type=attachment">http://mfiles.naver.net/a530b90a102e2f9fb752340638d5a6db7d2ad3ef/20110512_21_blogfile/herossg_1305211094659_5K4424_torrent/xcode_4_final.6233989.tpb.torrent?type=attachment</a>Jun's Papahttp://www.blogger.com/profile/05988238413662497858noreply@blogger.com0tag:blogger.com,1999:blog-7362238188344243679.post-72877923193458236772011-03-04T01:01:00.000-08:002011-03-04T01:21:20.280-08:00Corona SDK......02 - Sprite Animationㅎㅎ<br />
게임에 있어서 가장 중요한 Sprite Animation ..<br />
<br />
Corona SDK 는 두가지 방법을 지원한다.<br />
<br />
하나는 일정한 크기의 타일(?) 방식의 Sprite Animation .<br />
또 하나는 크기가 일정하지 않은 Sprite 를 연결해서 보여주는 방식.<br />
( Sprite Sheets 방식 )<br />
<br />
예를 보면 바로 이해 될듯. ㅋㅋ<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiBaXtS1jn-0-WNeCGlDxU83EEgpN3nlTLF5L79xGmWJcoz7vZAZ7u9bqiW-D1hLe6-UgbJsuWc_G5pnDRagvUd4oxrk-GN89KRnu22EtEe6eQj8qpnPYjTLKH_sYGevdf6iCT-fvhFP70/s1600/greenman.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiBaXtS1jn-0-WNeCGlDxU83EEgpN3nlTLF5L79xGmWJcoz7vZAZ7u9bqiW-D1hLe6-UgbJsuWc_G5pnDRagvUd4oxrk-GN89KRnu22EtEe6eQj8qpnPYjTLKH_sYGevdf6iCT-fvhFP70/s320/greenman.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;">크기가 일정한 Sprite.</div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmWsb1qfefnnXhalbNkqoyI-BOwx-rfCuwz0fM6HHjMl-86-oPQ6nXtgPkDRBkEOECi1IFWk3JmYuE_RBzZrzqo09gFHX3SLqX2VMpgLT1BbzGe_WuDWesaHJ0hoxfDLpAtS8vziHgEZ2J/s1600/uma.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="160" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmWsb1qfefnnXhalbNkqoyI-BOwx-rfCuwz0fM6HHjMl-86-oPQ6nXtgPkDRBkEOECi1IFWk3JmYuE_RBzZrzqo09gFHX3SLqX2VMpgLT1BbzGe_WuDWesaHJ0hoxfDLpAtS8vziHgEZ2J/s320/uma.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;">크기가 일정 하지 않은 Sprite</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">크기가 일정한 Sprite 를 사용하는게 훨씬 쉽다.ㅡ,.ㅡ</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;"></div><div class="separator" style="clear: both; text-align: left;">require "sprite" -- sprite 를 사용하기 위한 라이브러리(?) 추가</div><div class="separator" style="clear: both; text-align: left;">display.setStatusBar( display.HiddenStatusBar ) -- Status Bar 감추기</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">baseline = 280</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">-- sprite 객체(?) 이용하여 sheet2 를 생성하는데...</div><div class="separator" style="clear: both; text-align: left;">-- 파일 은 greenman 이고, 하나의 Sprite 타일이 128, 128 이다 라는 의미</div><div class="separator" style="clear: both; text-align: left;">local sheet2 = sprite.newSpriteSheet( "greenman.png", 128, 128 )</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">-- sprite 객체(?)인 sheet2 를 이용해서 sprite set 생성</div><div class="separator" style="clear: both; text-align: left;">-- sprite 타일 갯수가 1 ~ 15 라는 의미</div><div class="separator" style="clear: both; text-align: left;">-- 타일의 순서는 </div><div class="separator" style="clear: both; text-align: left;">-- 1 2 3 4</div><div class="separator" style="clear: both; text-align: left;">-- 5 6 7 8</div><div class="separator" style="clear: both; text-align: left;">-- 9 10 11 12</div><div class="separator" style="clear: both; text-align: left;">-- 13 14 15</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">local spriteSet2 = sprite.newSpriteSet(sheet2, 1, 15)</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">-- sprireset 을 setting 한다.</div><div class="separator" style="clear: both; text-align: left;">-- man 은 sprite 이름 정도로 이해 하면...</div><div class="separator" style="clear: both; text-align: left;">-- 1 .. 15 를 200 ms 동안 재생.</div><div class="separator" style="clear: both; text-align: left;">-- 젤 뒤에 0 이 나름 중요한 것이다. </div><div class="separator" style="clear: both; text-align: left;">-- 0 이면 무한 반복...</div><div class="separator" style="clear: both; text-align: left;">-- 1 보다 크면...숫자 만큼 반복.</div><div class="separator" style="clear: both; text-align: left;">-- -1 이면 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 ......3 2 1</div><div class="separator" style="clear: both; text-align: left;">-- 이렇게 반복. 됨.</div><div class="separator" style="clear: both; text-align: left;">sprite.add( spriteSet2, "man", 1, 15, 200, 0 ) </div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">-- 화면에 출력하기 위한 instance 생성...</div><div class="separator" style="clear: both; text-align: left;">-- 및 위치 설정.</div><div class="separator" style="clear: both; text-align: left;">local instance2 = sprite.newSprite( spriteSet2 )</div><div class="separator" style="clear: both; text-align: left;">instance2.x = 3 * display.contentWidth / 4 + 30</div><div class="separator" style="clear: both; text-align: left;">instance2.y = baseline - 55</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">-- man 으로 설정 된 놈을 불러 오고....</div><div class="separator" style="clear: both; text-align: left;">instance2:prepare("man")</div><div class="separator" style="clear: both; text-align: left;">-- animation paly...</div><div class="separator" style="clear: both; text-align: left;">instance2:play()</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">sprite sheet 는 담 기회에...</div><div class="separator" style="clear: both; text-align: left;">이건 솔직히 어려운게 아니라 넘 손이 많이 간다.ㅡ,.ㅡ</div><div><br />
</div><br />
<div class="separator" style="clear: both; text-align: left;"><br />
</div>Jun's Papahttp://www.blogger.com/profile/05988238413662497858noreply@blogger.com0tag:blogger.com,1999:blog-7362238188344243679.post-44818173990429196052011-03-02T01:22:00.000-08:002011-03-02T01:22:24.325-08:00Corona SDK......01 - Hello WorldCorona SDK 는 기본적으로 두개의 파일이 필요 한듯..<br />
<br />
config.lua -> 화명 해상도 등 설정 파일인듯...<br />
main.lua -> 이건 이름이 달라도 상관 없는듯...<br />
<br />
config.lua 내용<br />
<br />
-- config.lua<br />
<br />
application =<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>content =<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>width = 320, -- 가로 해상도<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>height = 480, -- 세로 해상도<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>scale = "zoomEven" -- zoom to fill screen, possibly cropping edges<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>},<br />
}<br />
<br />
Scale 는<br />
<span class="Apple-style-span" style="color: #333333; font-family: 'Lucida Grande', 'Trebuchet MS', Arial, sans-serif; font-size: 14px; line-height: 21px;"></span><br />
<ul style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; list-style-type: disc; margin-bottom: 1.5em; margin-left: 0px; margin-right: 1.5em; margin-top: 0px; padding-bottom: 0px; padding-left: 1.5em; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">"none" - turns off dynamic content scaling<br />
: Content 와 Sacle 를 무시(?)<br />
</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">"letterbox" - uniformly scales up content as much as possible, while still showing all content on the screen. This is similar to watching a widescreen DVD on a non-widescreen TV set, except that you can use offstage content to fill the "bleed" areas rather than displaying black bars.<br />
: 대충 봐서는...Content 를 가능한 최대로 표시 한다는 옵션.<br />
: 마치 DVD 영화를 TV 에서 보면 아래 위가 검은색으로 채워 지는것 같음.<br />
</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">"zoomEven" - uniformly scales up content to fill the screen, while preserving aspect ratio. Some content may appear offscreen, if the new screen has a different aspect ratio<br />
: 가로 세로 비율을 유지하면서 스크린에 내용 채우기.</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">"zoomStretch" - non-uniformly scales up content to fill the screen. All content will remain onscreen, but it may be stretched vertically or horizontally.<br />
: 비율을 유지 하지 않고 스크린에 맞게 내용 채우기.<br />
: 가로 / 세로 한쪽을 길어져서 보일 수 있음. </li>
</ul><br />
실제 게임을 만들기 위해서는 별다른 차이가 없어 보임. ( 현재까지는.. )<br />
<br />
main.lua<br />
<br />
<br />
local textObject = display.newText( "Hello World!", 50, 50, native.systemFont, 124 )<br />
-- 화면에 Text 박스(?) 를 생성함.<br />
-- display.newText Text 박스를 생성하는 Function 정도(?)<br />
textObject:setTextColor( 255,255,255 )<br />
-- Text 박스의 색 지정.<br />
<div><br />
</div><div>** display : displayObject 를 생성 할때 사용 하는놈..</div><div>Image 를 만들고 싶어면...</div><div>local image = display.newImage("xxx.png")</div><div><br />
</div><div>이렇게 해서 생성 할 수 있음. </div><div><br />
</div>Jun's Papahttp://www.blogger.com/profile/05988238413662497858noreply@blogger.com0tag:blogger.com,1999:blog-7362238188344243679.post-33447379897196575142011-01-28T14:25:00.000-08:002011-01-28T14:27:45.072-08:00Android 2D 게임 제작 - 02 ( with WiEngine )기본적인 환경 구성.<br />
<div><br />
</div><div>1. 우선 기본적인 Project 의 구성.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqstMYRB6KeHHUtx7_iHwP0vBW5kmwrOfLUiTIA2Nsdu-6K35kMi_hXUJDBYbDMQ78PEb0H7BCIyq4My9GsfaO8rV9xfGMa6hHuBYxgm0aygiMek7GKavYrvn_zk0rbm5mKrSxk01AFHrB/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqstMYRB6KeHHUtx7_iHwP0vBW5kmwrOfLUiTIA2Nsdu-6K35kMi_hXUJDBYbDMQ78PEb0H7BCIyq4My9GsfaO8rV9xfGMa6hHuBYxgm0aygiMek7GKavYrvn_zk0rbm5mKrSxk01AFHrB/s1600/4.png" /></a></div><br />
WiEngine 는 기본적으로 NDK 로 작성 되었다.<br />
그래서 속도는 비교적 빠른 편이지만, 호환성은...어느 정도 인지 장담하기 어렵다.<br />
<br />
내가 사용하는 기기인 갤럭시A ( SHW-M100S ) 에서는 별 무리 없이 잘 작동 한다.<br />
<br />
2. MainActivity -> 기본적인 Activity 이고 나머지는 이놈을 상속 해서 사용한다.<br />
<br />
<br />
package com.cnp.wizard;<br />
<br />
import android.app.Activity;<br />
import android.app.AlertDialog;<br />
import android.app.AlertDialog.Builder;<br />
import android.content.DialogInterface;<br />
import android.content.DialogInterface.OnClickListener;<br />
import android.os.Bundle;<br />
import android.text.TextUtils;<br />
<br />
import com.wiyun.engine.nodes.Director;<br />
import com.wiyun.engine.nodes.Director.IDirectorLifecycleListener;<br />
<br />
public abstract class MainActivity extends Activity implements IDirectorLifecycleListener {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>protected void onCreate(Bundle savedInstanceState) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> super.onCreate(savedInstanceState);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> Director.getInstance().addLifecycleListener(this);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>protected String checkPrecondition() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return null;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>protected void onPause() {<br />
super.onPause();<br />
<br />
Director.getInstance().pause();<br />
}<br />
<br />
@Override<br />
protected void onResume() {<br />
super.onResume();<br />
<br />
Director.getInstance().resume();<br />
}<br />
<br />
@Override<br />
protected void onDestroy() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Director.getInstance().end();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
super.onDestroy();<br />
}<br />
<br />
public void onDirectorEnded() {<br />
}<br />
<br />
public void onSurfaceChanged(int w, int h) {<br />
}<br />
<br />
public void onSurfaceCreated() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>final String error = checkPrecondition();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(!TextUtils.isEmpty(error)) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>runOnUiThread(new Runnable() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> public void run() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>AlertDialog.Builder builder = new Builder(MainActivity.this);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>builder.setMessage(error)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>.setNegativeButton("OK", new OnClickListener() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>public void onClick(DialogInterface dialog, int which) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>finish();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>}).show();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
});<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}<br />
<br />
public void onSurfaceDestroyed() {<br />
}<br />
}<br />
<div><br />
</div><div>3. mainActivity 를 상속한 GameActivity</div><div><div>/*</div><div> * Copyright (c) 2010 WiYun Inc.</div><div><br />
</div><div> * Permission is hereby granted, free of charge, to any person obtaining a copy</div><div> * of this software and associated documentation files (the "Software"), to deal</div><div> * in the Software without restriction, including without limitation the rights</div><div> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</div><div> * copies of the Software, and to permit persons to whom the Software is</div><div> * furnished to do so, subject to the following conditions:</div><div><br />
</div><div> * The above copyright notice and this permission notice shall be included in</div><div> * all copies or substantial portions of the Software.</div><div><br />
</div><div> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</div><div> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</div><div> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</div><div> * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</div><div> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</div><div> * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</div><div> * THE SOFTWARE.</div><div> */</div><div>package com.cnp.wizard;</div><div><br />
</div><div>import android.os.Bundle;</div><div>import android.view.MotionEvent;</div><div>import android.view.Window;</div><div>import android.view.WindowManager;</div><div><br />
</div><div>import com.wiyun.engine.actions.Action;</div><div>import com.wiyun.engine.actions.Animate;</div><div>import com.wiyun.engine.actions.IntervalAction;</div><div>import com.wiyun.engine.actions.MoveTo;</div><div>import com.wiyun.engine.actions.RepeatForever;</div><div>import com.wiyun.engine.actions.Sequence;</div><div>import com.wiyun.engine.nodes.AtlasAnimation;</div><div>import com.wiyun.engine.nodes.AtlasSprite;</div><div>import com.wiyun.engine.nodes.Director;</div><div>import com.wiyun.engine.nodes.Layer;</div><div>import com.wiyun.engine.nodes.Scene;</div><div>import com.wiyun.engine.nodes.Sprite;</div><div>import com.wiyun.engine.opengl.Texture2D;</div><div>import com.wiyun.engine.opengl.TextureAtlas;</div><div>import com.wiyun.engine.opengl.WYGLSurfaceView;</div><div>import com.wiyun.engine.tmx.ObjectGroup;</div><div>import com.wiyun.engine.tmx.TMXTileMap;</div><div>import com.wiyun.engine.types.WYRect;</div><div>import com.wiyun.engine.types.WYSize;</div><div>import com.wiyun.engine.utils.ResolutionIndependent;</div><div><br />
</div><div>public class GameActivity extends MainActivity {</div><div> private WYGLSurfaceView mGLSurfaceView;</div><div><br />
</div><div> @Override</div><div> protected void onCreate(Bundle savedInstanceState) {</div><div> super.onCreate(savedInstanceState);</div><div> requestWindowFeature(Window.FEATURE_NO_TITLE);</div><div> getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,</div><div> WindowManager.LayoutParams.FLAG_FULLSCREEN);</div><div><br />
</div><div> mGLSurfaceView = new WYGLSurfaceView(this);</div><div> setContentView(mGLSurfaceView);</div><div><br />
</div><div> // show FPS</div><div> Director.getInstance().setDisplayFPS(true);</div><div><br />
</div><div> Scene scene = Scene.make();</div><div> scene.addChild(new MyLayer());</div><div><br />
</div><div> // Make the Scene active</div><div> Director.getInstance().runWithScene(scene);</div><div> }</div><div><br />
</div><div> static class MyLayer extends Layer {</div><div> private static float ITEM_WIDTH = 0;</div><div> private static float ITEM_HEIGHT = 0;</div><div> private TMXTileMap<span class="Apple-tab-span" style="white-space: pre;"> </span> mMap;</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>private float mLastX;</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>private float mLastY;</div><div><br />
</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>public static final int TAG_SPRITE_MANAGER = 1; <span class="Apple-tab-span" style="white-space: pre;"> </span></div><div> public MyLayer() {</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span> ITEM_WIDTH = 47;//ResolutionIndependent.resolveDp(47);</div><div> ITEM_HEIGHT = 70;//ResolutionIndependent.resolveDp(70);</div><div><br />
</div><div> WYSize s = Director.getInstance().getWindowSize();</div><div><br />
</div><div> // add manager</div><div> TextureAtlas atlas = TextureAtlas.make(Texture2D.makePNG(R.drawable.mainc));</div><div> mMap = TMXTileMap.make(R.raw.t);</div><div> ObjectGroup ogs = mMap.getObjectGroup("Wall");</div><div> </div><div> </div><div> //og.</div><div> //addChild(mMap);</div><div><br />
</div><div> // add sprite</div><div> AtlasSprite sprite = AtlasSprite.make(WYRect.make(0, 0, ITEM_WIDTH, ITEM_HEIGHT), atlas);</div><div> addChild(sprite);</div><div> sprite.setPosition(s.width / 2, s.height / 2);</div><div> </div><div> // create animation and add it to atlas sprite</div><div> AtlasAnimation anim = new AtlasAnimation(0);</div><div> anim.addFrame(0.1f, </div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>frameAt(0, 0),</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>frameAt(1, 0),</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>frameAt(2, 0),</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>frameAt(3, 0), </div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>frameAt(4, 0),</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>frameAt(5, 0),</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>frameAt(6, 0),</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>frameAt(7, 0),</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>frameAt(8, 0)</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>);</div><div> </div><div> Animate a = Animate.make(anim);</div><div> sprite.runAction(RepeatForever.make(a));</div><div> setTouchEnabled(true);</div><div> }</div><div><br />
</div><div> @Override</div><div> public boolean wyTouchesBegan(MotionEvent event) {</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>mLastX = event.getX();</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>mLastY = event.getY();</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>return true;</div><div> } </div><div> private WYRect frameAt(int x, int y) {</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>return WYRect.make(x * ITEM_WIDTH, y * ITEM_HEIGHT, ITEM_WIDTH, ITEM_HEIGHT);</div><div> }</div><div> </div><div> @Override</div><div> public boolean wyTouchesMoved(MotionEvent event) {</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>// remember android event origin is not same as OpenGL</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>// you can use Director.getInstance().convertToGL(event.getX(), event.getY()) to convert it to GL coordinate</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>float x = event.getX();</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>float y = event.getY();</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>float deltaX = x - mLastX;</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>float deltaY = y - mLastY;</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>mLastX = x;</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>mLastY = y;</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span></div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>mMap.translate(deltaX, -deltaY);</div><div> <span class="Apple-tab-span" style="white-space: pre;"> </span>return true;</div><div> } </div><div> }</div><div>}</div></div><div><br />
</div><div>코드에 대한 자세한 설명...다음 포스트에서...^^<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL5yRPYEEB2yLT-yPo9SizNLXZz_Ukxpd6xofzRY-Y-MMzlJWhGDJYYa3Ifokk1RrUsK6UtDSRCiW5j4N2dUm4U6pgJw_z0iAO7-M0nNJkWMWm4y4gSltB8iEtRxxhOxI4pDGlrOqyI8aQ/s1600/5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL5yRPYEEB2yLT-yPo9SizNLXZz_Ukxpd6xofzRY-Y-MMzlJWhGDJYYa3Ifokk1RrUsK6UtDSRCiW5j4N2dUm4U6pgJw_z0iAO7-M0nNJkWMWm4y4gSltB8iEtRxxhOxI4pDGlrOqyI8aQ/s400/5.png" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;">실행 결과.^^</div><br />
</div></div>Jun's Papahttp://www.blogger.com/profile/05988238413662497858noreply@blogger.com1tag:blogger.com,1999:blog-7362238188344243679.post-10769017628242622572011-01-28T01:18:00.000-08:002011-01-28T01:18:11.576-08:00Android 2D 게임 제작 - 01 ( with WiEngine )개인 보관 차원의 자료임.<br />
<br />
<a href="http://www.wiyun.com/web/wiengine">WiEngine </a>를 이용한 2D 게임 제작.<br />
<a href="http://www.wiyun.com/site_media/wiki/attachments/WiEngineDemos_native_2.0.0.apk">WiEngine 에 대한 기본 예제</a>.<br />
<br />
기본적으로 WiEngine은 Cocos2D 를 형식을 따르고 있다.<br />
<br />
목표 게임<br />
<br />
<a href="http://ko.wikipedia.org/wiki/%EC%86%94%EB%A1%9C%EB%AA%AC_%ED%82%A4">Solomin's KEY</a><br />
<br />
<span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px; line-height: 22px;"><a href="http://ko.wikipedia.org/wiki/1986%EB%85%84" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: #0645ad; text-decoration: none;" title="1986년">1986년</a>에 <a class="new" href="http://ko.wikipedia.org/w/index.php?title=%ED%85%8C%ED%81%AC%EB%AA%A8&action=edit&redlink=1" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: #cc2200; text-decoration: none;" title="테크모 (존재하지 않는 문서)">테크모</a>에서 제작한 퍼즐 <a href="http://ko.wikipedia.org/wiki/%EC%95%84%EC%BC%80%EC%9D%B4%EB%93%9C_%EA%B2%8C%EC%9E%84" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: #0645ad; text-decoration: none;" title="아케이드 게임">아케이드 게임</a>이다. 총 50개의 스테이지로 구성되어 있으며 열쇠를 줍고 다음 관문으로 들어가는 문으로 들어가는 방식의 게임이다. 주인공이 벽돌을 만들고 허물 수 있는 능력을 가진 아주 독특한 구조의 게임이다.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh337ByMdZmZWAxAI0Rc1uKk9BMzVr69eUEgFaR7EnpM8gwXdpyeggd0QF_4j3kOS8L681WNGLrLsjeT6jB9ldG-auzykXltBOcCQEJ6oICaLWF5agDqFJLKzp6fI8Dv0nflUWfsBrq7YKH/s1600/solomon0.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh337ByMdZmZWAxAI0Rc1uKk9BMzVr69eUEgFaR7EnpM8gwXdpyeggd0QF_4j3kOS8L681WNGLrLsjeT6jB9ldG-auzykXltBOcCQEJ6oICaLWF5agDqFJLKzp6fI8Dv0nflUWfsBrq7YKH/s320/solomon0.jpg" width="320" /></a></div><br />
일단 시작. ㅋㅋJun's Papahttp://www.blogger.com/profile/05988238413662497858noreply@blogger.com0tag:blogger.com,1999:blog-7362238188344243679.post-77351711285621492262010-10-18T17:00:00.000-07:002011-01-28T01:05:31.595-08:00Android Game나의 두번째 Android 프로그램이자<br />
첫번째 게임 ...<br />
<br />
Carrier 2D<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOIkz7jFte9riBuVEBPHPBAEDc-jFvrcwmq9u_vEZZlpkdFFvC-hSfYX0k0uqP7FUXoUl6iKCsjX2DTUhCnUztSbOiXo5D9Km-ZK5g7ouWTpJ4eGI4HpKK-0rpEIiC1XPpmQuObl8GohIq/s1600/device1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOIkz7jFte9riBuVEBPHPBAEDc-jFvrcwmq9u_vEZZlpkdFFvC-hSfYX0k0uqP7FUXoUl6iKCsjX2DTUhCnUztSbOiXo5D9Km-ZK5g7ouWTpJ4eGI4HpKK-0rpEIiC1XPpmQuObl8GohIq/s1600/device1.png" /></a></div>ㅋㅋJun's Papahttp://www.blogger.com/profile/05988238413662497858noreply@blogger.com0