2023. 3. 14. 19:24ㆍcocos2dx
#define LAYER_BG_WIDTH 4096
#define LAYER_BG_HEIGHT 1024
#define LAYER_BG_BACK_TIME 120.0f //BG 기준 time
init()
{
//BG 영역
//BG repeat parameter
Texture2D::TexParams params;
params.minFilter = GL_NEAREST;
params.magFilter = GL_NEAREST;
params.wrapS = GL_REPEAT;
params.wrapT = GL_REPEAT;
//Rect영역은 texture의 좌상단부터 계산하는 점 유의
back = Sprite::create("bg/bg_base.png", Rect(0, 0, 768, LAYER_BG_HEIGHT));
back->getTexture()->setTexParameters(params);
back->setAnchorPoint(Vec2(0, 0));
back->setPosition(0, 0);
addChild(back, 0);
}
update(float delta)
{
//BG move
bgBackX += LAYER_BG_WIDTH / LAYER_BG_BACK_TIME * delta;
if (bgBackX >= LAYER_BG_WIDTH) bgBackX -= LAYER_BG_WIDTH;
back->setTextureRect(Rect(bgBackX, 0, 768, LAYER_BG_HEIGHT));
}
'cocos2dx' 카테고리의 다른 글
cocos2d observer pattern : notification center (0) | 2023.03.14 |
---|---|
ffmpeg && cocos2d 동영상 플레이어 (0) | 2023.03.14 |
애니메이션 재생후 셀프삭제, using schedule, CardinalSpline (0) | 2023.03.14 |
particle/using action function (0) | 2023.03.14 |
clipping node (0) | 2023.03.14 |