9.13总结
来源:互联网 发布:清华大学王斌算法考试 编辑:程序博客网 时间:2024/06/04 19:17
道具的实现,运用文本api,在场景中显示出金币的数量
for (int i = 0; i < ItemVec.size(); i++){
if (aa->getBoundingBox().intersectsRect(ItemVec.at(i)->getBoundingBox())){
coin1 += 1;
ItemVec.at(i)->removeFromParent();
ItemVec.eraseObject(ItemVec.at(i));
char string[20] = { 0 };
sprintf(string, "coin:%d", coin1);
auto label2 = (Label*)getChildByTag(12);
label2->setString(string);
}
}
飞机和生命值道具的碰撞,然后删除
for (int j = 0; j < HpVec.size(); j++){
if (abc->getBoundingBox().intersectsRect(HpVec.at(j)->getBoundingBox())){
HpVec.at(j)->removeFromParent();
HpVec.eraseObject(HpVec.at(j));
heroHp += 100;
}
}
飞机hp的边界要注意,否则会出现打不死boss ,而且我机不死亡的现象
if (heroHp > 0){
for (int j = 0; j < BultVec.size(); j++){
if (abc->getBoundingBox().intersectsRect(BultVec.at(j)->getBoundingBox())){
heroHp-=10;
BultVec.at(j)->removeFromParent();
BultVec.eraseObject(BultVec.at(j));
char string[10] = {0};
sprintf(string, "HP:%d", heroHp);
auto label1 = (Label*)getChildByTag(10);
label1->setString(string);
CCLOG("%d", heroHp);
}
}
}
if (heroHp<=0){
//this->unscheduleAllSelectors();
auto scene = GameScene2::createScene();
Director::getInstance()->replaceScene(TransitionFade::create(2, scene, Color3B::WHITE));
}
boss的文本,扣血,也同样要注意边界
for (int i = 0; i < ddd.size(); i++)
{
for (j = 0; j < aaa.size(); j++)
{
if (ddd.at(i)->getBoundingBox().intersectsRect(aaa.at(j)->getBoundingBox()))
{
bosshp -=10;
//d1->remove4(ddd.at(i));
a1->remove(aaa.at(j));
char string[20] = { 0 };
sprintf(string, "bosshp :%d", bosshp);
auto label3 = (Label*)getChildByTag(8);
label3->setString(string);
if (bosshp <= 0){
d1->remove4(ddd.at(i));
bosshp = 10000;
}
for (int i = 0; i < ItemVec.size(); i++){
if (aa->getBoundingBox().intersectsRect(ItemVec.at(i)->getBoundingBox())){
coin1 += 1;
ItemVec.at(i)->removeFromParent();
ItemVec.eraseObject(ItemVec.at(i));
char string[20] = { 0 };
sprintf(string, "coin:%d", coin1);
auto label2 = (Label*)getChildByTag(12);
label2->setString(string);
}
}
飞机和生命值道具的碰撞,然后删除
for (int j = 0; j < HpVec.size(); j++){
if (abc->getBoundingBox().intersectsRect(HpVec.at(j)->getBoundingBox())){
HpVec.at(j)->removeFromParent();
HpVec.eraseObject(HpVec.at(j));
heroHp += 100;
}
}
飞机hp的边界要注意,否则会出现打不死boss ,而且我机不死亡的现象
if (heroHp > 0){
for (int j = 0; j < BultVec.size(); j++){
if (abc->getBoundingBox().intersectsRect(BultVec.at(j)->getBoundingBox())){
heroHp-=10;
BultVec.at(j)->removeFromParent();
BultVec.eraseObject(BultVec.at(j));
char string[10] = {0};
sprintf(string, "HP:%d", heroHp);
auto label1 = (Label*)getChildByTag(10);
label1->setString(string);
CCLOG("%d", heroHp);
}
}
}
if (heroHp<=0){
//this->unscheduleAllSelectors();
auto scene = GameScene2::createScene();
Director::getInstance()->replaceScene(TransitionFade::create(2, scene, Color3B::WHITE));
}
boss的文本,扣血,也同样要注意边界
for (int i = 0; i < ddd.size(); i++)
{
for (j = 0; j < aaa.size(); j++)
{
if (ddd.at(i)->getBoundingBox().intersectsRect(aaa.at(j)->getBoundingBox()))
{
bosshp -=10;
//d1->remove4(ddd.at(i));
a1->remove(aaa.at(j));
char string[20] = { 0 };
sprintf(string, "bosshp :%d", bosshp);
auto label3 = (Label*)getChildByTag(8);
label3->setString(string);
if (bosshp <= 0){
d1->remove4(ddd.at(i));
bosshp = 10000;
}
0 0
- 9.13总结
- 总结
- 总结
- 总结
- 总结
- 总结!
- 总结
- 总结.
- 总结。
- 总结
- 总结
- 总结
- 总结
- 总结
- 总结
- 总结
- 总结
- 总结
- Linux_Ubuntu_openwrt_编译环境准备
- javax.mail.AuthenticationFailedException: 550
- 【LeetCode】240. Search a 2D Matrix II (Medium)
- BFS广度优先搜索(5)(亦可以用DFS)--hdu1241(poj1562)(基础题)
- 397.Longest Increasing Continuous Subsequence-最长上升连续子序列(容易题)
- 9.13总结
- Leetcode解题报告:215. Kth Largest Element in an Array
- java项目从win上布署到linux上报java.lang.ArrayIndexOutOfBoundsException错误
- Linux_Ubuntu_openWrt源码目录结构
- Linux 命令:wget
- mysql数据库设计小技巧
- LintCode:最长连续序列
- C#读取网卡地址的几种方法
- Java线程总结(十三):并发包------线程返回结果Callable和 Future