加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sprite

发布时间:2020-12-14 17:07:11 所属栏目:百科 来源:网络整理
导读:?? DrawNode* rect = DrawNode::create(); //rect-setAnchorPoint(Point(1,1));//这里个值没有用 rect-drawRect(Point(0,0),Point(100,100),Color4F(255,255,100));//这里的默认anchorpoint值为0 //rect-drawRect(Point(300,300),Point(200,200),100)); //re
??

DrawNode* rect = DrawNode::create();
//rect->setAnchorPoint(Point(1,1));//这里个值没有用
rect->drawRect(Point(0,0),Point(100,100),Color4F(255,255,100));//这里的默认anchorpoint值为0
//rect->drawRect(Point(300,300),Point(200,200),100));
//rect->setPosition(Point(100,100));//设置其位置
this->addChild(rect,1);

//Sprite* sp1 = Sprite::create();
//sp1->setTexture("menu_background.jpg");

//Sprite* sp1 = Sprite::create("menu_background.jpg");


//auto bath = SpriteBatchNode::create("Hello.png");
//Sprite* sp1 = Sprite::createWithTexture(bath->getTexture());

//根据缓存plist中的sprite frame来创建,这种用的比较多
//SpriteBatchNode* node = SpriteBatchNode::create("Hello.png");
//Sprite* sp1 = Sprite::createWithTexture(node->getTexture());

Sprite* sp1 = Sprite::createWithSpriteFrame(SpriteFrame::create("Hello.png",Rect(0,480,320)));
sp1->setAnchorPoint(Point(0,0));
//sp1->setPosition(Point(10,10));
sp1->setTag(100);
this->addChild(sp1,0);

schedule(schedule_selector(SpriteTest::callback),10);//调用时间


return true;
}

void SpriteTest::callback(float dt) { Sprite* sp1 = (Sprite*)this->getChildByTag(100); sp1->setTexture("HelloWorld.png"); sp1->setPosition(100,100); sp1->setRotation(-90);//这里的旋转没有时间设置而是直接到位的 }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读