Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #366 from natural-law/master
fixed #574
- Loading branch information
Showing
35 changed files
with
1,398 additions
and
11 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// Bug-1159.m | ||
// Z-Fighting in iPad 2 | ||
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=1159 | ||
// | ||
// Created by Greg Woods on 4/5/11. | ||
// Copyright 2011 Westlake Design. All rights reserved. | ||
// | ||
|
||
#include "Bug-1159.h" | ||
|
||
CCScene* Bug1159Layer::scene() | ||
{ | ||
CCScene *pScene = CCScene::node(); | ||
Bug1159Layer* layer = Bug1159Layer::node(); | ||
pScene->addChild(layer); | ||
|
||
return pScene; | ||
} | ||
|
||
bool Bug1159Layer::init() | ||
{ | ||
if (BugsTestBaseLayer::init()) | ||
{ | ||
CCSize s = CCDirector::sharedDirector()->getWinSize(); | ||
|
||
CCLayerColor *background = CCLayerColor::layerWithColor(ccc4(255, 0, 255, 255)); | ||
addChild(background); | ||
|
||
CCLayerColor *sprite_a = CCLayerColor::layerWithColorWidthHeight(ccc4(255, 0, 0, 255), 700, 700); | ||
sprite_a->setAnchorPoint(ccp(0.5f, 0.5f)); | ||
sprite_a->setIsRelativeAnchorPoint(true); | ||
sprite_a->setPosition(ccp(0.0, s.height/2)); | ||
addChild(sprite_a); | ||
|
||
sprite_a->runAction(CCRepeatForever::actionWithAction((CCActionInterval*) CCSequence::actions( | ||
CCMoveTo::actionWithDuration(1.0f, ccp(1024.0, 384.0)), | ||
CCMoveTo::actionWithDuration(1.0f, ccp(0.0, 384.0)), | ||
NULL))); | ||
|
||
CCLayerColor *sprite_b = CCLayerColor::layerWithColorWidthHeight(ccc4(0, 0, 255, 255), 400, 400); | ||
sprite_b->setAnchorPoint(ccp(0.5f, 0.5f)); | ||
sprite_b->setIsRelativeAnchorPoint(true); | ||
sprite_b->setPosition(ccp(s.width/2, s.height/2)); | ||
addChild(sprite_b); | ||
|
||
CCMenuItemLabel *label = CCMenuItemLabel::itemWithLabel(CCLabelTTF::labelWithString("Flip Me", "Helvetica", 24), this, menu_selector(Bug1159Layer::callBack)); | ||
CCMenu *menu = CCMenu::menuWithItems(label, NULL); | ||
menu->setPosition(ccp(s.width - 200, 50.0)); | ||
addChild(menu); | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
void Bug1159Layer::callBack(CCObject* pSender) | ||
{ | ||
CCDirector::sharedDirector()->replaceScene(CCTransitionPageTurn::transitionWithDuration(1.0f, Bug1159Layer::scene(), false)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef __BUG_1159_H__ | ||
#define __BUG_1159_H__ | ||
|
||
#include "BugsTest.h" | ||
|
||
class Bug1159Layer : public BugsTestBaseLayer | ||
{ | ||
public: | ||
virtual bool init(); | ||
static CCScene* scene(); | ||
void callBack(CCObject* pSender); | ||
|
||
LAYER_NODE_FUNC(Bug1159Layer); | ||
}; | ||
|
||
#endif // __BUG_1159_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
// | ||
// Bug-1174 | ||
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=1174 | ||
// | ||
|
||
#include "Bug-1174.h" | ||
|
||
int check_for_error( CCPoint p1, CCPoint p2, CCPoint p3, CCPoint p4, float s, float t ) | ||
{ | ||
// the hit point is p3 + t * (p4 - p3); | ||
// the hit point also is p1 + s * (p2 - p1); | ||
|
||
CCPoint p4_p3 = ccpSub( p4, p3); | ||
CCPoint p4_p3_t = ccpMult(p4_p3, t); | ||
CCPoint hitPoint1 = ccpAdd( p3, p4_p3_t); | ||
|
||
CCPoint p2_p1 = ccpSub( p2, p1); | ||
CCPoint p2_p1_s = ccpMult(p2_p1, s); | ||
CCPoint hitPoint2 = ccpAdd( p1, p2_p1_s); | ||
|
||
// Since float has rounding errors, only check if diff is < 0.05 | ||
if( (fabs( hitPoint1.x - hitPoint2.x) > 0.1f) || ( fabs(hitPoint1.y - hitPoint2.y) > 0.1f) ) | ||
{ | ||
CCLog("ERROR: (%f,%f) != (%f,%f)", hitPoint1.x, hitPoint1.y, hitPoint2.x, hitPoint2.y); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
bool Bug1174Layer::init() | ||
{ | ||
if (BugsTestBaseLayer::init()) | ||
{ | ||
// // seed | ||
// srand(0); | ||
|
||
CCPoint A,B,C,D,p1,p2,p3,p4; | ||
float s,t; | ||
|
||
int err=0; | ||
int ok=0; | ||
|
||
// | ||
// Test 1. | ||
// | ||
CCLog("Test1 - Start"); | ||
for( int i=0; i < 10000; i++) | ||
{ | ||
// A | b | ||
// ----- | ||
// c | d | ||
float ax = CCRANDOM_0_1() * -5000; | ||
float ay = CCRANDOM_0_1() * 5000; | ||
|
||
// a | b | ||
// ----- | ||
// c | D | ||
float dx = CCRANDOM_0_1() * 5000; | ||
float dy = CCRANDOM_0_1() * -5000; | ||
|
||
// a | B | ||
// ----- | ||
// c | d | ||
float bx = CCRANDOM_0_1() * 5000; | ||
float by = CCRANDOM_0_1() * 5000; | ||
|
||
// a | b | ||
// ----- | ||
// C | d | ||
float cx = CCRANDOM_0_1() * -5000; | ||
float cy = CCRANDOM_0_1() * -5000; | ||
|
||
A = ccp(ax,ay); | ||
B = ccp(bx,by); | ||
C = ccp(cx,cy); | ||
D = ccp(dx,dy); | ||
if( ccpLineIntersect( A, D, B, C, &s, &t) ) { | ||
if( check_for_error(A, D, B, C, s, t) ) | ||
err++; | ||
else | ||
ok++; | ||
} | ||
} | ||
CCLog("Test1 - End. OK=%i, Err=%i", ok, err); | ||
|
||
// | ||
// Test 2. | ||
// | ||
CCLog("Test2 - Start"); | ||
|
||
p1 = ccp(220,480); | ||
p2 = ccp(304,325); | ||
p3 = ccp(264,416); | ||
p4 = ccp(186,416); | ||
s = 0.0f; | ||
t = 0.0f; | ||
if( ccpLineIntersect(p1, p2, p3, p4, &s, &t) ) | ||
check_for_error(p1, p2, p3, p4, s,t ); | ||
|
||
CCLog("Test2 - End"); | ||
|
||
|
||
// | ||
// Test 3 | ||
// | ||
CCLog("Test3 - Start"); | ||
|
||
ok=0; | ||
err=0; | ||
for( int i=0;i<10000;i++) | ||
{ | ||
// A | b | ||
// ----- | ||
// c | d | ||
float ax = CCRANDOM_0_1() * -500; | ||
float ay = CCRANDOM_0_1() * 500; | ||
p1 = ccp(ax,ay); | ||
|
||
// a | b | ||
// ----- | ||
// c | D | ||
float dx = CCRANDOM_0_1() * 500; | ||
float dy = CCRANDOM_0_1() * -500; | ||
p2 = ccp(dx,dy); | ||
|
||
|
||
////// | ||
|
||
float y = ay - ((ay - dy) /2.0f); | ||
|
||
// a | b | ||
// ----- | ||
// C | d | ||
float cx = CCRANDOM_0_1() * -500; | ||
p3 = ccp(cx,y); | ||
|
||
// a | B | ||
// ----- | ||
// c | d | ||
float bx = CCRANDOM_0_1() * 500; | ||
p4 = ccp(bx,y); | ||
|
||
s = 0.0f; | ||
t = 0.0f; | ||
if( ccpLineIntersect(p1, p2, p3, p4, &s, &t) ) { | ||
if( check_for_error(p1, p2, p3, p4, s,t ) ) | ||
err++; | ||
else | ||
ok++; | ||
} | ||
} | ||
|
||
CCLog("Test3 - End. OK=%i, err=%i", ok, err); | ||
return true; | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef __BUG_1174_H__ | ||
#define __BUG_1174_H__ | ||
|
||
#include "BugsTest.h" | ||
|
||
class Bug1174Layer : public BugsTestBaseLayer | ||
{ | ||
public: | ||
virtual bool init(); | ||
}; | ||
|
||
#endif // __BUG_1174_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// Bug-350 | ||
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=350 | ||
// | ||
|
||
#include "Bug-350.h" | ||
|
||
bool Bug350Layer::init() | ||
{ | ||
if (BugsTestBaseLayer::init()) | ||
{ | ||
CCSize size = CCDirector::sharedDirector()->getWinSize(); | ||
CCSprite *background = CCSprite::spriteWithFile("Default.png"); | ||
background->setPosition(ccp(size.width/2, size.height/2)); | ||
addChild(background); | ||
return true; | ||
} | ||
|
||
return false; | ||
} |
Oops, something went wrong.