将"Cocos2d-x 精灵碰撞检测(方法一)" update函数修改一下。
使用精灵boundingBox函数获取直接精灵边界框, 不用自己计算精灵矩形大小了,还比较精确,然后调用intersectsRect计算2个精灵矩形是否存在集。
代码:
void HelloWorld::update(float delta)
{
//返回精灵边界框
CCRect cr1 = sp1->b...
分类:
其他好文 时间:
2014-06-07 01:44:56
阅读次数:
187
class Solution {
public:
void dfs(vector<vector >&result, vectorcombination, vector&candidates, int kth, int k, int index2add){
// 当前正在确定组合中的第kth个数,将把候选集candidates中index2add索引位的值作为第kth个数加到组合中
combination.push_back(ca...
分类:
其他好文 时间:
2014-06-07 01:21:47
阅读次数:
220
移动:
-(void) touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint touchLoc = [touch locationInNode:self];
// Log touch location
CCLOG(@"Moved sprite to @ %@",NSStringFromCGPo...
分类:
移动开发 时间:
2014-06-05 08:30:44
阅读次数:
352
声明函数碰撞检测函数,两个精灵和重写update
bool isCollision( CCPoint p1,CCPoint p2,int w1,int h1,int w2,int h2 );
CCSprite *sp2;
CCSprite *sp1;
virtual void update(float delta);
//重写触摸事件
virtual void regi...
分类:
其他好文 时间:
2014-06-05 07:12:15
阅读次数:
236
用于大型程序的工具--异常处理[续2]八、自动资源释放 考虑下面函数:void f()
{
vector v;
string s;
while (cin >> s)
{
v.push_back(s);
}
string *p = new string[v.size()];
//...
delete p;
}
在正...
分类:
编程语言 时间:
2014-06-05 06:07:27
阅读次数:
393
Wrote by mutouyun. (http://darkc.at/cxx-type-list/)
群里有个朋友要实现这么一个功能:如何在编译期把一个函数类型的参数减少一个。
简单来说,就是实现下面这个模板:
remove_func_par::type; // type = void(int, long)
根据输入的编译期整数,把函数参数表里对应的参数干掉一个。
为了实现...
分类:
编程语言 时间:
2014-06-05 06:04:09
阅读次数:
273
http://acm.hdu.edu.cn/showproblem.php?pid=2544
入门级别 floyed和dijkstra都可以
//Dijkstra
#include
#include
#define N 105
#define inf 0xfffffff
int dis[N],map[N][N],vis[N],n;
void dijkstra()
{
int m,k...
分类:
其他好文 时间:
2014-06-05 05:39:32
阅读次数:
196
这里是发送的代码:SendVarData是转码后发送函数 1 /// 2 /// 发送文件 3
/// 4 /// 5 private void SendFileToClient(string userName) 6 ...
分类:
其他好文 时间:
2014-05-31 14:26:40
阅读次数:
446
类似 153=1^3+5^3+3^3 这样的数就叫做水仙花数#include int
main(void){ int bw,sw,gw; int i; int count=0; for(i=100;i<=999;i++){
bw=i/100; //取出百位上的数 sw=i%100/10;/...
分类:
其他好文 时间:
2014-05-31 14:22:33
阅读次数:
173
#include int main(void){ int year1, month1, day1,
midDay; int year2, month2, day2; int totalDate1; int totalDate2; printf("请输入两个日期
年 月 日\n"); scanf("%...
分类:
其他好文 时间:
2014-05-31 13:58:57
阅读次数:
240