'잡다한것들전부/팁'에 해당되는 글 38건
- 2013.12.10 포물선 운동 관련 소스
- 2013.12.03 헥사 게임 알고리즘
- 2013.12.02 비쥬얼드 로직
- 2013.12.02 비쥬얼드 3개 블록 맞추는 로직
- 2013.12.02 cocos2d-x 3.0 관련 컴포넌트 사용
- 2013.12.02 ios7 UITableView 사용시 배경화면 흰색으로 나오는 현상
- 2013.12.02 iOS7 상태바 안보이게 설정하기
- 2013.11.20 관련 사이트
#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
using namespace cocos2d;
using namespace CocosDenshion;
CCScene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
sprite = CCSprite::create("CloseNormal.png");
this->addChild(sprite);
sprite->setPosition(ccp(20, winSize.height/2));
//힘
int Force = 5;
//각도 조절
float x = Force * cos(25);
float y = Force * sin(25);
//벡터값
vector = CCPoint(x, y);
time = 0.0f;
initPos = sprite->getPosition();
CCLog("%f, %f" , x,y);
this->schedule(schedule_selector(HelloWorld::gameLogic));
return true;
}
void HelloWorld::gameLogic(float dt)
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//CCLog("gameLogic!");
time += dt;
//시간에 따른 포물선 운동 공식
float x = vector.x * time;
float y = vector.y * time - (9.8f/2.0f * time * time);
CCPoint pos = sprite->getPosition();
sprite->setPosition(ccp(pos.x+x,pos.y+y));
if(sprite->getPositionY() < 0)
{
time = 0;
sprite->setPosition(ccp(20, winSize.height/2));
}
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
'잡다한것들전부 > 팁' 카테고리의 다른 글
| 중급 개발자가 되는 방법 5가지 (0) | 2013.12.16 |
|---|---|
| 배경 무한 스크롤링 (0) | 2013.12.11 |
| 포물선 운동 관련 소스 (0) | 2013.12.10 |
| 헥사 게임 알고리즘 (0) | 2013.12.03 |
| 비쥬얼드 로직 (0) | 2013.12.02 |
| 비쥬얼드 3개 블록 맞추는 로직 (0) | 2013.12.02 |
만약 상쇄되어 여러개가 그 밑으로 내려가서 반응하는 경우를 어렵게 생각하실거 같습니다만
모두를 하나씩 생각한다면 어렵지 않습니다.
일단 기본방법은 주위의 블럭을 비교해서 같은 것인지 체크를 합니다. 2차원 배열을 하나 만들어서 없어져야 할 블럭칸을 마킹 합니다.
마킹하고 또 주위 블럭을 검사하고 마킹합니다. 마킹한 블럭은 검사할 필요 없죠. 재귀호출 함수나 길찾기 알고리즘을 이용할 수 도 있습니다.
그래픽툴에서 색칠하기 공식도 유사하구요. 이렇게 해서 1단계 마킹처리가 끝나면 그 마킹된 위치의 블럭들을 없애는 처리를 합니다.
그러면 블럭사이에 빈 공간이 생길 수 있는데 블럭을 내리고 블럭의 칸들을 하나씩 검사해서 위 과정을 뒤풀이 합니다.
'잡다한것들전부 > 팁' 카테고리의 다른 글
| 배경 무한 스크롤링 (0) | 2013.12.11 |
|---|---|
| 포물선 운동 관련 소스 (0) | 2013.12.10 |
| 헥사 게임 알고리즘 (0) | 2013.12.03 |
| 비쥬얼드 로직 (0) | 2013.12.02 |
| 비쥬얼드 3개 블록 맞추는 로직 (0) | 2013.12.02 |
| cocos2d-x 3.0 관련 컴포넌트 사용 (0) | 2013.12.02 |
package {
'잡다한것들전부 > 팁' 카테고리의 다른 글
| 포물선 운동 관련 소스 (0) | 2013.12.10 |
|---|---|
| 헥사 게임 알고리즘 (0) | 2013.12.03 |
| 비쥬얼드 로직 (0) | 2013.12.02 |
| 비쥬얼드 3개 블록 맞추는 로직 (0) | 2013.12.02 |
| cocos2d-x 3.0 관련 컴포넌트 사용 (0) | 2013.12.02 |
| ios7 UITableView 사용시 배경화면 흰색으로 나오는 현상 (0) | 2013.12.02 |
var grid:Array = [[2,3,2,2,2,4],
[ .. ]]; //multidimensional array
var matches:uint;
var gemType:uint;
for(col = 0; col < grid.length; col++){
matches = 0;
gemType = 0; //Reserve 0 for the empty state. If we make it a normal gem type, then only 2 are needed to match for the start.
for(i = 0; i < grid[0].length; i++){
if(grid[col][i] == gemType){
matches++;
}
if(grid[col][i] != gemType || i == grid[0].length - 1){ //subtract 1 because arrays start at 0
if(matches >= 3){
removeMatches(blah);
}
gemType = grid[col][i];
matches = 1;
}
}
}int item = grid[x,y];
if(grid[x-1,y]==item)
{
int step=x;
int matches =2;
while(grid[step-1,y]==item)
{
step++;
matches++
}
if(matches>2)
//remove all matching items
}
else if(grid[x+1,y]==item
//....
else if(grid[x,y-1==item)
//...
else if(grid[x,y+1]==item)
//... public int getHMatchSize(int row, int column)
{
int returnMe = getMatchValue(row, 0, column, 1);
if (returnMe < 3)
{
return 0;
}
else return returnMe;
}
public int getVMatchSize(int row, int column)
{
int returnMe = getMatchValue(row, 1, column, 0);
if (returnMe < 3)
{
return 0;
}
else return returnMe;
}
/// <summary>
/// I return the match size.
/// </summary>
/// <param name="row"></param>
/// <param name="rowDelta">1 means look vertically. Dont set both deltas to 1.</param>
/// <param name="column"></param>
/// <param name="columnDelta">1 means look horizontally. Dont set both deltas to 1.</param>
/// <returns>The number of contiguous matching things</returns>
public int getMatchValue(int row, int rowDelta, int column, int columnDelta)
{
int[] start = getEndItem(row, -1 * rowDelta, column, -1 * columnDelta);
int[] end = getEndItem(row, rowDelta, column, columnDelta);
int returnMe = 0;
returnMe += end[0] - start[0];
returnMe += end[1] - start[1];
return returnMe;
}
/// <summary>
/// I will return the end of a sequence of matching items.
/// </summary>
/// <param name="row">start here</param>
/// <param name="column">start here</param>
private int[] getEndItem(int row, int rowDelta, int column, int columnDelta)
{
Gem matchGem = new Gem(-1);
int[] returnMe = new int[2];
if (boardSpace[row + rowDelta][column + columnDelta] == boardSpace[row][column])
{
return getEndItem(row + rowDelta, rowDelta, column + columnDelta, columnDelta);
}
else
{
returnMe[0] = row;
returnMe[1] = column;
return returnMe;
}
}'잡다한것들전부 > 팁' 카테고리의 다른 글
| 헥사 게임 알고리즘 (0) | 2013.12.03 |
|---|---|
| 비쥬얼드 로직 (0) | 2013.12.02 |
| 비쥬얼드 3개 블록 맞추는 로직 (0) | 2013.12.02 |
| cocos2d-x 3.0 관련 컴포넌트 사용 (0) | 2013.12.02 |
| ios7 UITableView 사용시 배경화면 흰색으로 나오는 현상 (0) | 2013.12.02 |
| iOS7 상태바 안보이게 설정하기 (0) | 2013.12.02 |
참고하시면 좋을것 같아서 퍼옵니다.
출처 : http://www.dev3d.net/bbs/view.php?id=pds&page=3&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=headnum&desc=asc&no=106
'잡다한것들전부 > 팁' 카테고리의 다른 글
| 비쥬얼드 로직 (0) | 2013.12.02 |
|---|---|
| 비쥬얼드 3개 블록 맞추는 로직 (0) | 2013.12.02 |
| cocos2d-x 3.0 관련 컴포넌트 사용 (0) | 2013.12.02 |
| ios7 UITableView 사용시 배경화면 흰색으로 나오는 현상 (0) | 2013.12.02 |
| iOS7 상태바 안보이게 설정하기 (0) | 2013.12.02 |
| 관련 사이트 (0) | 2013.11.20 |
ios7은 UITableView의 셀 배경이 기본으로 흰색으로 설정되있는 것 같습니다.
cellForRowAtIndexPath 함수에 아래의 내용을 추가합니다.
cell.backgroundColor = [UIColor clearColor]; cell.backgroundView = [[UIView new] autorelease]; cell.selectedBackgroundView = [[UIView new] autorelease];
'잡다한것들전부 > 팁' 카테고리의 다른 글
| 비쥬얼드 로직 (0) | 2013.12.02 |
|---|---|
| 비쥬얼드 3개 블록 맞추는 로직 (0) | 2013.12.02 |
| cocos2d-x 3.0 관련 컴포넌트 사용 (0) | 2013.12.02 |
| ios7 UITableView 사용시 배경화면 흰색으로 나오는 현상 (0) | 2013.12.02 |
| iOS7 상태바 안보이게 설정하기 (0) | 2013.12.02 |
| 관련 사이트 (0) | 2013.11.20 |
iOS가 7 로 되면서 시간과 배터리 등의 정보가
상태바에 표시되는 증상이 있습니다. into.plist 파일에 View controller-based status bar appearance를 Add
Row하시고 속성값을 NO로 세팅해주면 됩니다. 이런 현상이 사라지게 됩니다.
'잡다한것들전부 > 팁' 카테고리의 다른 글
| 비쥬얼드 로직 (0) | 2013.12.02 |
|---|---|
| 비쥬얼드 3개 블록 맞추는 로직 (0) | 2013.12.02 |
| cocos2d-x 3.0 관련 컴포넌트 사용 (0) | 2013.12.02 |
| ios7 UITableView 사용시 배경화면 흰색으로 나오는 현상 (0) | 2013.12.02 |
| iOS7 상태바 안보이게 설정하기 (0) | 2013.12.02 |
| 관련 사이트 (0) | 2013.11.20 |
http://paralaxer.com/
http://www.supersuraccoon-cocos2d.com/2011/09/17/sticky-demo-resource-list-keep-updating/
'잡다한것들전부 > 팁' 카테고리의 다른 글
| 비쥬얼드 로직 (0) | 2013.12.02 |
|---|---|
| 비쥬얼드 3개 블록 맞추는 로직 (0) | 2013.12.02 |
| cocos2d-x 3.0 관련 컴포넌트 사용 (0) | 2013.12.02 |
| ios7 UITableView 사용시 배경화면 흰색으로 나오는 현상 (0) | 2013.12.02 |
| iOS7 상태바 안보이게 설정하기 (0) | 2013.12.02 |
| 관련 사이트 (0) | 2013.11.20 |
kasa080622cppcompsys.ppt

