cocos2dx源码:相框PhotoFrame

cocos2dx源码:相框PhotoFrame,第1张

概述头文件PhotoFrame.h #ifndef _PHOTOFRAME_H_#define _PHOTOFRAME_H_#include "cocos2d.h"#include "GmbsCocos.h"#include "extensions/cocos-ext.h"using namespace cocos2d::ui;NS_CC_BEGINclass PhotoFram

头文件PhotoFrame.h

#ifndef _PHOTOFRAME_H_#define _PHOTOFRAME_H_#include "cocos2d.h"#include "GmbsCocos.h"#include "extensions/cocos-ext.h"using namespace cocos2d::ui;NS_CC_BEGINclass PhotoFrame : public Layercolor{public:    ~PhotoFrame();    static PhotoFrame* create(const char* filename,const color4B& color = color4B(255,255,0));    virtual bool init(const char* filename);    voID decorate(Node* photo,float horiz = 0,float vert = 0);    voID inflate(float wInf,float hInf);protected:    ui::Scale9Sprite* m_frameSprite;};NS_CC_END#endif

cpp文件PhotoFrame.cpp

#include "PhotoFrame.h"NS_CC_BEGINPhotoFrame::~PhotoFrame(){}PhotoFrame* PhotoFrame::create(const char* filename,const color4B& color){    PhotoFrame* pobLayer = new PhotoFrame();    if (pobLayer && pobLayer->initWithcolor(color) && pobLayer->init(filename))    {        pobLayer->autorelease();        return pobLayer;    }    else    {        CC_SAFE_DELETE(pobLayer);        return NulL;    }}bool PhotoFrame::init(const char* filename){    m_frameSprite =  ui::Scale9Sprite::create(filename);    this->addChild(m_frameSprite);    return true;}voID PhotoFrame::decorate(Node* photo,float wInf,float hInf){    photo->addChild(this);    Size size = photo->getContentSize();    size.wIDth += wInf;    size.height += hInf;    this->setContentSize(size);    m_frameSprite->setContentSize(size);    GmbsPoint pt;    pt.reset(m_frameSprite);    pt.xMIDdleAlign(this).yMIDdleAlign(this);    m_frameSprite->setposition(pt);    pt.reset(this);    pt.xMIDdleAlign(photo).yMIDdleAlign(photo);    this->setposition(pt);}voID PhotoFrame::inflate(float wInf,float hInf){    Size size = this->getContentSize();    size.wIDth += wInf;    size.height += hInf;    this->setContentSize(size);    m_frameSprite->setContentSize(size);    GmbsPoint pt;    Node* photo = getParent();    pt.reset(m_frameSprite);    pt.xMIDdleAlign(photo).yMIDdleAlign(photo);    m_frameSprite->setposition(pt);    pt.reset(this);    pt.xMIDdleAlign(photo).yMIDdleAlign(photo);    this->setposition(pt);}NS_CC_END
总结

以上是内存溢出为你收集整理的cocos2dx源码:相框PhotoFrame全部内容,希望文章能够帮你解决cocos2dx源码:相框PhotoFrame所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1081200.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存