Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions effectNodes-for-cocos2dx-3x/code/shatter/ensShatterNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ bool CshatterSprite::init(const string&texFileName){
int nRow=(int)m_grid.size();
int nCol=(nRow==0?0:(int)m_grid[0].size());
const float halfGridSideLen=0.5*m_gridSideLen;

int offsetX = this->getTextureRect().origin.x;
int offsetY = this->getTextureRect().origin.y;

for(int i=0;i<nRow;i++){
for(int j=0;j<nCol;j++){
Cfrag*frag=m_grid[i][j];
//position
float x=j*m_gridSideLen+halfGridSideLen;
float y=contentSize.height-(i*m_gridSideLen+halfGridSideLen);
//texture and textureRect
frag->setTextureRect(CCRect(x-halfGridSideLen,(contentSize.height-y)-halfGridSideLen,m_gridSideLen,m_gridSideLen));
frag->setTextureRect(CCRect(x-halfGridSideLen+offsetX,(contentSize.height-y)-halfGridSideLen+offsetY,m_gridSideLen,m_gridSideLen));
//set position
frag->setPosition(ccp(x,y));
//scale
Expand Down Expand Up @@ -162,4 +166,4 @@ void CshatterAction::update(float time){//the time actually is percentage, namel



namespace_ens_end
namespace_ens_end