本文整理汇总了C++中CCSpriteFrame::setOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ CCSpriteFrame::setOffset方法的具体用法?C++ CCSpriteFrame::setOffset怎么用?C++ CCSpriteFrame::setOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCSpriteFrame
的用法示例。
在下文中一共展示了CCSpriteFrame::setOffset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFrames
NS_CC_BEGIN
void TFFrameInfo::getFrames(std::vector<CCSpriteFrame*> &frames)
{
frames.clear();
for ( std::vector<std::string>::iterator iter = pngs.begin(); iter != pngs.end();++iter)
{
std::string &pngName = *iter;
CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(pngName.c_str());
CCSpriteFrame *frame = CCSpriteFrame::frameWithTexture(texture,CCRectMake(0,0,texture->getContentSize().width,texture->getContentSize().height));
if (frame)
{
frames.push_back(frame);
frame->retain();
frame->setOffset(ccp(0,0));
}
}
}
示例2: takeNode
/**
int frameType; //帧类型
int actionType; // 行为类型
int actionId; // 行为id
int needTime; // 帧播完的时间
int direction; // 方向
int framesId; // 帧号
int conbineType; // 下一个串接类型
*/
void TFActionManager::takeNode(script::tixmlCodeNode *node)
{
if (!node) return;
int index = 0;
_actions.clear();
if (node->equal("Config") && _actions.empty())
{
// 加载行为
script::tixmlCodeNode actionsNode = node->getFirstChildNode("actions");
int actionsIndex = 0;
while (actionsNode.isValid())
{
actionsNode.getAttr("id",actionsIndex);
TFAction action;
script::tixmlCodeNode actionNode = actionsNode.getFirstChildNode("action");
while (actionNode.isValid())
{
std::map<int,TFActionInfo> frames; // 8个方向的帧
script::tixmlCodeNode framesNode = actionNode.getFirstChildNode("frames");
while (framesNode.isValid())
{
TFActionInfo actionInfo;
framesNode.getAttr("dir",actionInfo.direction); // 方向
framesNode.getAttr("framesid",actionInfo.framesId); // 帧号
framesNode.getAttr("conbinetype",actionInfo.conbineType); // 合并类型
framesNode.getAttr("frametype",actionInfo.frameType); // 是否自身播放
framesNode.getAttr("needtime",actionInfo.needTime); // 所需时间
if (!actionInfo.needTime) actionInfo.needTime = 1;
framesNode.getAttr("actiontype",actionInfo.actionType); // 行为类型
framesNode.getAttr("distance",actionInfo.distance);
framesNode.getAttr("angle",actionInfo.angle);
framesNode.getAttr("offsetx",actionInfo.offset.x);
framesNode.getAttr("offsety",actionInfo.offset.y);
framesNode.getAttr("anchorx",actionInfo.anchor.x);
framesNode.getAttr("anchory",actionInfo.anchor.y);
frames[actionInfo.direction] = actionInfo;
framesNode = framesNode.getNextNode("frames");
}
action.actions.push_back(frames);
actionNode = actionNode.getNextNode("action");
}
_actions[actionsIndex] = action; //获取到一个行为
actionsNode = actionsNode.getNextNode("actions");
}
// 记载帧数
script::tixmlCodeNode frameNode = node->getFirstChildNode("frames");
while (frameNode.isValid())
{
std::string type = frameNode.getAttr("type");
TFFrameInfo frameInfo;
frameNode.getAttr("id",frameInfo.framesId);
if (type == std::string("files"))
{
script::tixmlCodeNode fileNode = frameNode.getFirstChildNode("file");
while (fileNode.isValid())
{
std::string pngName = fileNode.getAttr("value");
frameInfo.pngs.push_back(pngName);
CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(pngName.c_str());
CCSpriteFrame *frame = CCSpriteFrame::frameWithTexture(texture,CCRectMake(0,0,texture->getContentSize().width,texture->getContentSize().height));
if (frame)
{
frameInfo.frames.push_back(frame);
// frame->retain();
frame->setOffset(ccp(0,0));
}
fileNode = fileNode.getNextNode("file");
}
}
if (type == std::string("framecache"))
{
std::string plistName = frameNode.getAttr("plistname");
std::string pngName = frameNode.getAttr("pngname");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(plistName.c_str(), pngName.c_str());
script::tixmlCodeNode fileNode = frameNode.getFirstChildNode("file");
while (fileNode.isValid())
{
std::string value = fileNode.getAttr("value");
CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(value.c_str());
if (frame)
{
frameInfo.frames.push_back(frame);
// frame->retain();
}
fileNode = fileNode.getNextNode("file");
}
//.........这里部分代码省略.........