mirror of
https://github.com/wu736139669/SmallGame_Cocos2dx.git
synced 2026-08-06 06:41:44 +00:00
first commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// GameLayerTable.cpp
|
||||
// OnceAgain
|
||||
//
|
||||
// Created by mac on 14-4-18.
|
||||
//
|
||||
//
|
||||
|
||||
#include "GameLayerTable.h"
|
||||
#define BOUNCE_DURATION 1.5
|
||||
GameLayerTable::GameLayerTable()
|
||||
{
|
||||
|
||||
}
|
||||
GameLayerTable::~GameLayerTable()
|
||||
{
|
||||
}
|
||||
|
||||
void GameLayerTable::setContentOffset(CCPoint offset, bool animated)
|
||||
{
|
||||
if (animated)
|
||||
{ //animate scrolling
|
||||
this->setContentOffsetInDuration(offset, BOUNCE_DURATION);
|
||||
}
|
||||
else
|
||||
{ //set the container position directly
|
||||
if (!m_bBounceable)
|
||||
{
|
||||
const CCPoint minOffset = this->minContainerOffset();
|
||||
const CCPoint maxOffset = this->maxContainerOffset();
|
||||
|
||||
offset.x = MAX(minOffset.x, MIN(maxOffset.x, offset.x));
|
||||
offset.y = MAX(minOffset.y, MIN(maxOffset.y, offset.y));
|
||||
}
|
||||
|
||||
m_pContainer->setPosition(offset);
|
||||
|
||||
if (m_pDelegate != NULL)
|
||||
{
|
||||
m_pDelegate->scrollViewDidScroll(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameLayerTable* GameLayerTable::create(CCSize size, CCNode* container/* = NULL*/)
|
||||
{
|
||||
GameLayerTable* pRet = new GameLayerTable();
|
||||
if (pRet && pRet->initWithViewSize(size, container))
|
||||
{
|
||||
pRet->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_DELETE(pRet);
|
||||
}
|
||||
return pRet;
|
||||
}
|
||||
Reference in New Issue
Block a user