背景和头像缺失
This commit is contained in:
59
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-1159.cpp
Normal file
59
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-1159.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// 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"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool Bug1159Layer::init()
|
||||
{
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
auto background = LayerColor::create(Color4B(255, 0, 255, 255));
|
||||
addChild(background);
|
||||
|
||||
auto sprite_a = LayerColor::create(Color4B(255, 0, 0, 255), 700, 700);
|
||||
sprite_a->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
sprite_a->ignoreAnchorPointForPosition(false);
|
||||
sprite_a->setPosition(0.0f, s.height/2);
|
||||
addChild(sprite_a);
|
||||
|
||||
sprite_a->runAction(RepeatForever::create(Sequence::create(
|
||||
MoveTo::create(1.0f, Vec2(1024.0f, 384.0f)),
|
||||
MoveTo::create(1.0f, Vec2(0.0f, 384.0f)),
|
||||
nullptr)));
|
||||
|
||||
auto sprite_b = LayerColor::create(Color4B(0, 0, 255, 255), 400, 400);
|
||||
sprite_b->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
sprite_b->ignoreAnchorPointForPosition(false);
|
||||
sprite_b->setPosition(s.width/2, s.height/2);
|
||||
addChild(sprite_b);
|
||||
|
||||
auto label = MenuItemLabel::create(Label::createWithSystemFont("Flip Me", "Helvetica", 24), CC_CALLBACK_1(Bug1159Layer::callBack, this) );
|
||||
auto menu = Menu::create(label, nullptr);
|
||||
menu->setPosition(s.width - 200.0f, 50.0f);
|
||||
addChild(menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bug1159Layer::callBack(Ref* sender)
|
||||
{
|
||||
Director::getInstance()->replaceScene(TransitionPageTurn::create(1.0f, Bug1159Layer::create(), false));
|
||||
}
|
||||
|
||||
void Bug1159Layer::onExit()
|
||||
{
|
||||
BugsTestBase::onExit();
|
||||
}
|
||||
17
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-1159.h
Normal file
17
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-1159.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef __BUG_1159_H__
|
||||
#define __BUG_1159_H__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class Bug1159Layer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
virtual bool init() override;
|
||||
virtual void onExit() override;
|
||||
|
||||
void callBack(cocos2d::Ref* sender);
|
||||
|
||||
CREATE_FUNC(Bug1159Layer);
|
||||
};
|
||||
|
||||
#endif // __BUG_1159_H__
|
||||
163
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-1174.cpp
Normal file
163
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-1174.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
//
|
||||
// Bug-1174
|
||||
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=1174
|
||||
//
|
||||
|
||||
#include "Bug-1174.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
int check_for_error( Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4, float s, float t );
|
||||
|
||||
int check_for_error( Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4, float s, float t )
|
||||
{
|
||||
// the hit point is p3 + t * (p4 - p3);
|
||||
// the hit point also is p1 + s * (p2 - p1);
|
||||
|
||||
auto p4_p3 = p4 - p3;
|
||||
auto p4_p3_t = p4_p3 * t;
|
||||
auto hitPoint1 = p3 + p4_p3_t;
|
||||
|
||||
auto p2_p1 = p2 - p1;
|
||||
auto p2_p1_s = p2_p1 * s;
|
||||
auto hitPoint2 = 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) )
|
||||
{
|
||||
log("ERROR: (%f,%f) != (%f,%f)", hitPoint1.x, hitPoint1.y, hitPoint2.x, hitPoint2.y);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Bug1174Layer::init()
|
||||
{
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
// // seed
|
||||
// srand(0);
|
||||
|
||||
Vec2 A,B,C,D,p1,p2,p3,p4;
|
||||
float s,t;
|
||||
|
||||
int err=0;
|
||||
int ok=0;
|
||||
|
||||
//
|
||||
// Test 1.
|
||||
//
|
||||
log("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 = Vec2(ax,ay);
|
||||
B = Vec2(bx,by);
|
||||
C = Vec2(cx,cy);
|
||||
D = Vec2(dx,dy);
|
||||
if( Vec2::isLineIntersect( A, D, B, C, &s, &t) ) {
|
||||
if( check_for_error(A, D, B, C, s, t) )
|
||||
err++;
|
||||
else
|
||||
ok++;
|
||||
}
|
||||
}
|
||||
log("Test1 - End. OK=%i, Err=%i", ok, err);
|
||||
|
||||
//
|
||||
// Test 2.
|
||||
//
|
||||
log("Test2 - Start");
|
||||
|
||||
p1 = Vec2(220,480);
|
||||
p2 = Vec2(304,325);
|
||||
p3 = Vec2(264,416);
|
||||
p4 = Vec2(186,416);
|
||||
s = 0.0f;
|
||||
t = 0.0f;
|
||||
if( Vec2::isLineIntersect(p1, p2, p3, p4, &s, &t) )
|
||||
check_for_error(p1, p2, p3, p4, s,t );
|
||||
|
||||
log("Test2 - End");
|
||||
|
||||
|
||||
//
|
||||
// Test 3
|
||||
//
|
||||
log("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 = Vec2(ax,ay);
|
||||
|
||||
// a | b
|
||||
// -----
|
||||
// c | D
|
||||
float dx = CCRANDOM_0_1() * 500;
|
||||
float dy = CCRANDOM_0_1() * -500;
|
||||
p2 = Vec2(dx,dy);
|
||||
|
||||
|
||||
//////
|
||||
|
||||
float y = ay - ((ay - dy) /2.0f);
|
||||
|
||||
// a | b
|
||||
// -----
|
||||
// C | d
|
||||
float cx = CCRANDOM_0_1() * -500;
|
||||
p3 = Vec2(cx,y);
|
||||
|
||||
// a | B
|
||||
// -----
|
||||
// c | d
|
||||
float bx = CCRANDOM_0_1() * 500;
|
||||
p4 = Vec2(bx,y);
|
||||
|
||||
s = 0.0f;
|
||||
t = 0.0f;
|
||||
if( Vec2::isLineIntersect(p1, p2, p3, p4, &s, &t) ) {
|
||||
if( check_for_error(p1, p2, p3, p4, s,t ) )
|
||||
err++;
|
||||
else
|
||||
ok++;
|
||||
}
|
||||
}
|
||||
|
||||
log("Test3 - End. OK=%i, err=%i", ok, err);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
14
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-1174.h
Normal file
14
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-1174.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __BUG_1174_H__
|
||||
#define __BUG_1174_H__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class Bug1174Layer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Bug1174Layer);
|
||||
|
||||
virtual bool init() override;
|
||||
};
|
||||
|
||||
#endif // __BUG_1174_H__
|
||||
73
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-12847.cpp
Normal file
73
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-12847.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// Bug-12847.cpp
|
||||
// cocos2d_tests
|
||||
//
|
||||
// Issue: https://github.com/cocos2d/cocos2d-x/issues/12847
|
||||
// Please test in iPhone5 +
|
||||
//
|
||||
//
|
||||
|
||||
#include "Bug-12847.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool Bug12847Layer::init()
|
||||
{
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
Director::getInstance()->setProjection(Director::Projection::_2D);
|
||||
auto _visibleSize = Director::getInstance()->getVisibleSize();
|
||||
|
||||
//Create with Sprite
|
||||
{
|
||||
sprite1 = Sprite::create("Images/bug12847_sprite.png");
|
||||
sprite1->getTexture()->setAliasTexParameters();
|
||||
sprite1->setPosition(Vec2(_visibleSize.width/3, 50));
|
||||
this->addChild(sprite1, 1);
|
||||
|
||||
sprite2 = Sprite::create("Images/bug12847_sprite.png");
|
||||
sprite2->getTexture()->setAliasTexParameters();
|
||||
sprite2->setPosition(sprite1->getPosition() + Vec2(0.0f, sprite1->getContentSize().height));
|
||||
this->addChild(sprite2, 1);
|
||||
}
|
||||
//Create with SpriteFrame
|
||||
{
|
||||
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/bug12847_spriteframe.plist");
|
||||
|
||||
sprite3 = Sprite::createWithSpriteFrameName("bug12847_sprite2.png");
|
||||
sprite3->getTexture()->setAliasTexParameters();
|
||||
sprite3->setPosition(Vec2(_visibleSize.width * 2/3, 50));
|
||||
this->addChild(sprite3, 1);
|
||||
|
||||
sprite4 = Sprite::createWithSpriteFrameName("bug12847_sprite2.png");
|
||||
sprite4->getTexture()->setAliasTexParameters();
|
||||
sprite4->setPosition(sprite3->getPosition() + Vec2(0.0f, sprite3->getContentSize().height));
|
||||
this->addChild(sprite4, 1);
|
||||
}
|
||||
|
||||
this->scheduleUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bug12847Layer::update(float dt)
|
||||
{
|
||||
sprite1->setPositionY(sprite1->getPositionY() + 0.01f);
|
||||
sprite2->setPositionY(sprite2->getPositionY() + 0.01f);
|
||||
sprite3->setPositionY(sprite3->getPositionY() + 0.01f);
|
||||
sprite4->setPositionY(sprite4->getPositionY() + 0.01f);
|
||||
}
|
||||
|
||||
void Bug12847Layer::onEnter()
|
||||
{
|
||||
BugsTestBase::onEnter();
|
||||
Director::getInstance()->setClearColor(Color4F::RED);
|
||||
}
|
||||
|
||||
void Bug12847Layer::onExit()
|
||||
{
|
||||
Director::getInstance()->setClearColor(Color4F::BLACK);
|
||||
BugsTestBase::onExit();
|
||||
}
|
||||
26
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-12847.h
Normal file
26
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-12847.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef __cocos2d_tests__Bug_12847__
|
||||
#define __cocos2d_tests__Bug_12847__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class Bug12847Layer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Bug12847Layer);
|
||||
|
||||
virtual bool init() override;
|
||||
|
||||
protected:
|
||||
virtual void update(float dt) override;
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
|
||||
private:
|
||||
|
||||
cocos2d::Sprite* sprite1;
|
||||
cocos2d::Sprite* sprite2;
|
||||
cocos2d::Sprite* sprite3;
|
||||
cocos2d::Sprite* sprite4;
|
||||
};
|
||||
|
||||
#endif /* defined(__cocos2d_tests__Bug_12847__) */
|
||||
91
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-14327.cpp
Normal file
91
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-14327.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// Bug-14327.cpp
|
||||
// cocos2d_tests
|
||||
//
|
||||
// Issue: https://github.com/cocos2d/cocos2d-x/pull/14327
|
||||
// Please test in Windows
|
||||
//
|
||||
//
|
||||
|
||||
#include "Bug-14327.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool Bug14327Layer::init()
|
||||
{
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
auto glview = Director::getInstance()->getOpenGLView();
|
||||
auto visibleOrigin = glview->getVisibleOrigin();
|
||||
auto visibleSize = glview->getVisibleSize();
|
||||
|
||||
auto pBg = Sprite::create("Images/HelloWorld.png");
|
||||
pBg->setPosition(Vec2(visibleOrigin.x + visibleSize.width / 2, visibleOrigin.y + visibleSize.height / 2));
|
||||
addChild(pBg);
|
||||
|
||||
_removeTime = time(nullptr) + 20;
|
||||
|
||||
_TTFShowTime = Label::createWithSystemFont("Edit control will be removed after 00:20!", "Arial", 20);
|
||||
_TTFShowTime->setPosition(Vec2(visibleOrigin.x + visibleSize.width / 2, visibleOrigin.y + visibleSize.height - 60));
|
||||
this->addChild(_TTFShowTime);
|
||||
|
||||
|
||||
auto editBoxSize = Size(visibleSize.width - 100, visibleSize.height * 0.1);
|
||||
|
||||
std::string pNormalSprite = "extensions/green_edit.png";
|
||||
_edit = ui::EditBox::create(editBoxSize + Size(0, 20), ui::Scale9Sprite::create(pNormalSprite));
|
||||
_edit->setPosition(Vec2(visibleOrigin.x + visibleSize.width / 2, visibleOrigin.y + visibleSize.height / 2));
|
||||
_edit->setFontColor(Color3B::RED);
|
||||
_edit->setReturnType(ui::EditBox::KeyboardReturnType::DONE);
|
||||
_edit->setDelegate(this);
|
||||
this->addChild(_edit);
|
||||
|
||||
this->scheduleUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bug14327Layer::update(float dt)
|
||||
{
|
||||
long delta = _removeTime - time(nullptr);
|
||||
if (delta > 0)
|
||||
{
|
||||
ldiv_t ret = ldiv(delta, 60L);
|
||||
char str[100];
|
||||
snprintf(str, 100, "%s%.2ld:%.2ld", "Edit control will be removed after ", ret.quot, ret.rem);
|
||||
_TTFShowTime->setString(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
_edit->removeFromParent();
|
||||
_edit = nullptr;
|
||||
_TTFShowTime->setString("Edit control has been removed!\nIt should not crash.");
|
||||
this->unscheduleUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void Bug14327Layer::editBoxEditingDidBegin(cocos2d::ui::EditBox* editBox)
|
||||
{
|
||||
log("editBox %p DidBegin !", editBox);
|
||||
}
|
||||
|
||||
void Bug14327Layer::editBoxEditingDidEnd(cocos2d::ui::EditBox* editBox)
|
||||
{
|
||||
log("editBox %p DidEnd !", editBox);
|
||||
}
|
||||
|
||||
void Bug14327Layer::editBoxTextChanged(cocos2d::ui::EditBox* editBox, const std::string& text)
|
||||
{
|
||||
log("editBox %p TextChanged, text: %s ", editBox, text.c_str());
|
||||
}
|
||||
|
||||
void Bug14327Layer::editBoxReturn(ui::EditBox* editBox)
|
||||
{
|
||||
log("editBox %p was returned !", editBox);
|
||||
}
|
||||
|
||||
#endif
|
||||
31
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-14327.h
Normal file
31
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-14327.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef __cocos2d_tests__Bug_14327__
|
||||
#define __cocos2d_tests__Bug_14327__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
class Bug14327Layer : public BugsTestBase, public cocos2d::ui::EditBoxDelegate
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Bug14327Layer);
|
||||
|
||||
virtual bool init() override;
|
||||
|
||||
virtual void editBoxEditingDidBegin(cocos2d::ui::EditBox* editBox) override;
|
||||
virtual void editBoxEditingDidEnd(cocos2d::ui::EditBox* editBox) override;
|
||||
virtual void editBoxTextChanged(cocos2d::ui::EditBox* editBox, const std::string& text) override;
|
||||
virtual void editBoxReturn(cocos2d::ui::EditBox* editBox) override;
|
||||
|
||||
protected:
|
||||
virtual void update(float dt) override;
|
||||
|
||||
private:
|
||||
time_t _removeTime;
|
||||
cocos2d::Label *_TTFShowTime;
|
||||
cocos2d::ui::EditBox* _edit;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* defined(__cocos2d_tests__Bug_14327__) */
|
||||
22
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-350.cpp
Normal file
22
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-350.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Bug-350
|
||||
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=350
|
||||
//
|
||||
|
||||
#include "Bug-350.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool Bug350Layer::init()
|
||||
{
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
auto background = Sprite::create("Hello.png");
|
||||
background->setPosition(size.width/2, size.height/2);
|
||||
addChild(background);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
14
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-350.h
Normal file
14
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-350.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __BUG_350_H__
|
||||
#define __BUG_350_H__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class Bug350Layer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Bug350Layer);
|
||||
|
||||
virtual bool init() override;
|
||||
};
|
||||
|
||||
#endif // __BUG_350_H__
|
||||
62
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-422.cpp
Normal file
62
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-422.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// Bug-422 test case by lhunath
|
||||
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=422
|
||||
//
|
||||
|
||||
#include "Bug-422.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool Bug422Layer::init()
|
||||
{
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bug422Layer::reset()
|
||||
{
|
||||
static int localtag = 0;
|
||||
localtag++;
|
||||
|
||||
// TO TRIGGER THE BUG:
|
||||
// remove the itself from parent from an action
|
||||
// The menu will be removed, but the instance will be alive
|
||||
// and then a new node will be allocated occupying the memory.
|
||||
// => CRASH BOOM BANG
|
||||
auto node = getChildByTag(localtag-1);
|
||||
log("Menu: %p", node);
|
||||
removeChild(node, true);
|
||||
// [self removeChildByTag:localtag-1 cleanup:NO];
|
||||
|
||||
auto item1 = MenuItemFont::create("One", CC_CALLBACK_1(Bug422Layer::menuCallback, this) );
|
||||
log("MenuItemFont: %p", item1);
|
||||
MenuItem *item2 = MenuItemFont::create("Two", CC_CALLBACK_1(Bug422Layer::menuCallback, this) );
|
||||
auto menu = Menu::create(item1, item2, nullptr);
|
||||
menu->alignItemsVertically();
|
||||
|
||||
float x = CCRANDOM_0_1() * 50;
|
||||
float y = CCRANDOM_0_1() * 50;
|
||||
menu->setPosition(menu->getPosition() + Vec2(x,y));
|
||||
addChild(menu, 0, localtag);
|
||||
|
||||
//[self check:self];
|
||||
}
|
||||
|
||||
void Bug422Layer::check(Node* t)
|
||||
{
|
||||
auto& children = t->getChildren();
|
||||
for(const auto &child : children) {
|
||||
log("%p, rc: %d", child, child->getReferenceCount());
|
||||
check(child);
|
||||
}
|
||||
}
|
||||
|
||||
void Bug422Layer::menuCallback(Ref* sender)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
18
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-422.h
Normal file
18
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-422.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef __BUG_422_H__
|
||||
#define __BUG_422_H__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class Bug422Layer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Bug422Layer);
|
||||
|
||||
virtual bool init() override;
|
||||
|
||||
void reset();
|
||||
void check(Node* target);
|
||||
void menuCallback(cocos2d::Ref* sender);
|
||||
};
|
||||
|
||||
#endif // __BUG_422_H__
|
||||
48
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-458/Bug-458.cpp
Normal file
48
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-458/Bug-458.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// Bug-458 test case by nedrafehi
|
||||
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=458
|
||||
//
|
||||
|
||||
#include "Bug-458.h"
|
||||
#include "QuestionContainerSprite.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool Bug458Layer::init()
|
||||
{
|
||||
if(BugsTestBase::init())
|
||||
{
|
||||
// ask director the the window size
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
|
||||
auto question = new (std::nothrow) QuestionContainerSprite();
|
||||
auto question2 = new (std::nothrow) QuestionContainerSprite();
|
||||
question->init();
|
||||
question2->init();
|
||||
|
||||
// [question setContentSize:CGSizeMake(50,50)];
|
||||
// [question2 setContentSize:CGSizeMake(50,50)];
|
||||
|
||||
auto sprite = MenuItemSprite::create(question2, question, CC_CALLBACK_1(Bug458Layer::selectAnswer, this) );
|
||||
auto layer = LayerColor::create(Color4B(0,0,255,255), 100, 100);
|
||||
question->release();
|
||||
question2->release();
|
||||
|
||||
auto layer2 = LayerColor::create(Color4B(255,0,0,255), 100, 100);
|
||||
auto sprite2 = MenuItemSprite::create(layer, layer2, CC_CALLBACK_1(Bug458Layer::selectAnswer, this) );
|
||||
auto menu = Menu::create(sprite, sprite2, nullptr);
|
||||
menu->alignItemsVerticallyWithPadding(100);
|
||||
menu->setPosition(size.width / 2, size.height / 2);
|
||||
|
||||
// add the label as a child to this Layer
|
||||
addChild(menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bug458Layer::selectAnswer(Ref* sender)
|
||||
{
|
||||
log("Selected");
|
||||
}
|
||||
15
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-458/Bug-458.h
Normal file
15
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-458/Bug-458.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef __BUG_458_H__
|
||||
#define __BUG_458_H__
|
||||
|
||||
#include "../BugsTest.h"
|
||||
|
||||
class Bug458Layer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Bug458Layer);
|
||||
|
||||
virtual bool init() override;
|
||||
void selectAnswer(cocos2d::Ref* sender);
|
||||
};
|
||||
|
||||
#endif // __BUG_458_H__
|
||||
@@ -0,0 +1,86 @@
|
||||
#include "QuestionContainerSprite.h"
|
||||
|
||||
#define kLabelTag
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool QuestionContainerSprite::init()
|
||||
{
|
||||
if (Sprite::init())
|
||||
{
|
||||
//Add label
|
||||
auto label = Label::createWithTTF("Answer 1", "fonts/arial.ttf", 12);
|
||||
label->setTag(100);
|
||||
|
||||
//Add the background
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
auto corner = Sprite::create("Images/bugs/corner.png");
|
||||
|
||||
int width = size.width * 0.9f - (corner->getContentSize().width * 2);
|
||||
int height = size.height * 0.15f - (corner->getContentSize().height * 2);
|
||||
auto layer = LayerColor::create(Color4B(255, 255, 255, 255 * .75), width, height);
|
||||
layer->setPosition(Vec2(-width / 2, -height / 2));
|
||||
|
||||
//First button is blue,
|
||||
//Second is red
|
||||
//Used for testing - change later
|
||||
static int a = 0;
|
||||
|
||||
if (a == 0)
|
||||
label->setColor(Color3B::BLUE);
|
||||
else
|
||||
{
|
||||
log("Color changed");
|
||||
label->setColor(Color3B::RED);
|
||||
}
|
||||
a++;
|
||||
addChild(layer);
|
||||
|
||||
corner->setPosition(Vec2(-(width / 2 + corner->getContentSize().width / 2), -(height / 2 + corner->getContentSize().height / 2)));
|
||||
addChild(corner);
|
||||
|
||||
auto corner2 = Sprite::create("Images/bugs/corner.png");
|
||||
corner2->setPosition(Vec2(-corner->getPosition().x, corner->getPosition().y));
|
||||
corner2->setFlippedX(true);
|
||||
addChild(corner2);
|
||||
|
||||
auto corner3 = Sprite::create("Images/bugs/corner.png");
|
||||
corner3->setPosition(Vec2(corner->getPosition().x, -corner->getPosition().y));
|
||||
corner3->setFlippedY(true);
|
||||
addChild(corner3);
|
||||
|
||||
auto corner4 = Sprite::create("Images/bugs/corner.png");
|
||||
corner4->setPosition(Vec2(corner2->getPosition().x, -corner2->getPosition().y));
|
||||
corner4->setFlippedX(true);
|
||||
corner4->setFlippedY(true);
|
||||
addChild(corner4);
|
||||
|
||||
auto edge = Sprite::create("Images/bugs/edge.png");
|
||||
edge->setScaleX(width);
|
||||
edge->setPosition(Vec2(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), corner->getPosition().y));
|
||||
addChild(edge);
|
||||
|
||||
auto edge2 = Sprite::create("Images/bugs/edge.png");
|
||||
edge2->setScaleX(width);
|
||||
edge2->setPosition(Vec2(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), -corner->getPosition().y));
|
||||
edge2->setFlippedY(true);
|
||||
addChild(edge2);
|
||||
|
||||
auto edge3 = Sprite::create("Images/bugs/edge.png");
|
||||
edge3->setRotation(90);
|
||||
edge3->setScaleX(height);
|
||||
edge3->setPosition(Vec2(corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2)));
|
||||
addChild(edge3);
|
||||
|
||||
auto edge4 = Sprite::create("Images/bugs/edge.png");
|
||||
edge4->setRotation(270);
|
||||
edge4->setScaleX(height);
|
||||
edge4->setPosition(Vec2(-corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2)));
|
||||
addChild(edge4);
|
||||
|
||||
addChild(label);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef __QUESTION_CONTAINER_SPRITE_H__
|
||||
#define __QUESTION_CONTAINER_SPRITE_H__
|
||||
|
||||
#include "cocos2d.h"
|
||||
|
||||
class QuestionContainerSprite : public cocos2d::Sprite
|
||||
{
|
||||
public:
|
||||
virtual bool init() override;
|
||||
};
|
||||
|
||||
#endif // __QUESTION_CONTAINER_SPRITE_H__
|
||||
101
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-624.cpp
Normal file
101
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-624.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
//
|
||||
// Bug-624
|
||||
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=624
|
||||
//
|
||||
|
||||
#include "Bug-624.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bug624Layer
|
||||
//
|
||||
////////////////////////////////////////////////////////
|
||||
Bug624Layer::~Bug624Layer()
|
||||
{
|
||||
Device::setAccelerometerEnabled(false);
|
||||
}
|
||||
|
||||
bool Bug624Layer::init()
|
||||
{
|
||||
if(BugsTestBase::init())
|
||||
{
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
auto label = Label::createWithTTF("Layer1", "fonts/Marker Felt.ttf", 36.0f);
|
||||
|
||||
label->setPosition(size.width/2, size.height/2);
|
||||
addChild(label);
|
||||
|
||||
Device::setAccelerometerEnabled(true);
|
||||
auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(Bug624Layer::onAcceleration, this));
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
|
||||
schedule(CC_SCHEDULE_SELECTOR(Bug624Layer::switchLayer), 5.0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bug624Layer::switchLayer(float dt)
|
||||
{
|
||||
unschedule(CC_SCHEDULE_SELECTOR(Bug624Layer::switchLayer));
|
||||
|
||||
auto scene = Scene::create();
|
||||
scene->addChild(Bug624Layer2::create(), 0);
|
||||
Director::getInstance()->replaceScene(TransitionFade::create(2.0f, scene, Color3B::WHITE));
|
||||
}
|
||||
|
||||
void Bug624Layer::onAcceleration(Acceleration* acc, Event* event)
|
||||
{
|
||||
log("Layer1 accel");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bug624Layer2
|
||||
//
|
||||
////////////////////////////////////////////////////////
|
||||
Bug624Layer2::~Bug624Layer2()
|
||||
{
|
||||
Device::setAccelerometerEnabled(false);
|
||||
}
|
||||
|
||||
bool Bug624Layer2::init()
|
||||
{
|
||||
if(BugsTestBase::init())
|
||||
{
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
auto label = Label::createWithTTF("Layer2", "fonts/Marker Felt.ttf", 36.0f);
|
||||
|
||||
label->setPosition(size.width/2, size.height/2);
|
||||
addChild(label);
|
||||
|
||||
Device::setAccelerometerEnabled(true);
|
||||
auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(Bug624Layer2::onAcceleration, this));
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
|
||||
|
||||
schedule(CC_SCHEDULE_SELECTOR(Bug624Layer2::switchLayer), 5.0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bug624Layer2::switchLayer(float dt)
|
||||
{
|
||||
unschedule(CC_SCHEDULE_SELECTOR(Bug624Layer::switchLayer));
|
||||
|
||||
auto scene = Scene::create();
|
||||
scene->addChild(Bug624Layer::create(), 0);
|
||||
Director::getInstance()->replaceScene(TransitionFade::create(2.0f, scene, Color3B::RED));
|
||||
}
|
||||
|
||||
void Bug624Layer2::onAcceleration(Acceleration* acc, Event* event)
|
||||
{
|
||||
log("Layer2 accel");
|
||||
}
|
||||
28
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-624.h
Normal file
28
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-624.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef __BUG_624_H__
|
||||
#define __BUG_624_H__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class Bug624Layer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
virtual ~Bug624Layer();
|
||||
virtual bool init() override;
|
||||
void switchLayer(float dt);
|
||||
virtual void onAcceleration(cocos2d::Acceleration* acc, cocos2d::Event* event);
|
||||
|
||||
CREATE_FUNC(Bug624Layer);
|
||||
};
|
||||
|
||||
class Bug624Layer2 : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
virtual ~Bug624Layer2();
|
||||
virtual bool init() override;
|
||||
void switchLayer(float dt);
|
||||
virtual void onAcceleration(cocos2d::Acceleration* acc, cocos2d::Event* event);
|
||||
|
||||
CREATE_FUNC(Bug624Layer2);
|
||||
};
|
||||
|
||||
#endif // __BUG_624_H__
|
||||
33
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-886.cpp
Normal file
33
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-886.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Bug-886
|
||||
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=886
|
||||
//
|
||||
|
||||
#include "Bug-886.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool Bug886Layer::init()
|
||||
{
|
||||
if(BugsTestBase::init())
|
||||
{
|
||||
// ask director the the window size
|
||||
// auto size = [[Director sharedDirector] winSize];
|
||||
|
||||
auto sprite = Sprite::create("Images/bugs/bug886.jpg");
|
||||
sprite->setAnchorPoint(Vec2::ZERO);
|
||||
sprite->setPosition(Vec2::ZERO);
|
||||
sprite->setScaleX(0.6f);
|
||||
addChild(sprite);
|
||||
|
||||
auto sprite2 = Sprite::create("Images/bugs/bug886.png");
|
||||
sprite2->setAnchorPoint(Vec2::ZERO);
|
||||
sprite2->setScaleX(0.6f);
|
||||
sprite2->setPosition(sprite->getContentSize().width * 0.6f + 10, 0);
|
||||
addChild(sprite2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
14
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-886.h
Normal file
14
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-886.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __BUG_886_H__
|
||||
#define __BUG_886_H__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class Bug886Layer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Bug886Layer);
|
||||
|
||||
virtual bool init() override;
|
||||
};
|
||||
|
||||
#endif // __BUG_886_H__
|
||||
24
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-899.cpp
Normal file
24
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-899.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Bug-899
|
||||
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=899
|
||||
//
|
||||
// Test coded by: JohnnyFlash
|
||||
//
|
||||
|
||||
#include "Bug-899.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool Bug899Layer::init()
|
||||
{
|
||||
// Director::getInstance()->enableRetinaDisplay(true);
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
auto bg = Sprite::create("Images/bugs/RetinaDisplay.jpg");
|
||||
addChild(bg, 0);
|
||||
bg->setAnchorPoint(Vec2::ZERO);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
14
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-899.h
Normal file
14
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-899.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __BUG_899_H__
|
||||
#define __BUG_899_H__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class Bug899Layer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Bug899Layer);
|
||||
|
||||
virtual bool init() override;
|
||||
};
|
||||
|
||||
#endif // __BUG_899_H__
|
||||
71
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-914.cpp
Normal file
71
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-914.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// HelloWorldLayer.m
|
||||
// EAGLViewBug
|
||||
//
|
||||
// Created by Wylan Werth on 7/5/10.
|
||||
// Copyright BanditBear Games 2010. All rights reserved.
|
||||
//
|
||||
|
||||
// Import the interfaces
|
||||
#include"Bug-914.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
// on "init" you need to initialize your instance
|
||||
bool Bug914Layer::init()
|
||||
{
|
||||
// always call "super" init
|
||||
// Apple recommends to re-assign "self" with the "super" return value
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
auto listener = EventListenerTouchAllAtOnce::create();
|
||||
listener->onTouchesBegan = CC_CALLBACK_2(Bug914Layer::onTouchesBegan, this);
|
||||
listener->onTouchesMoved = CC_CALLBACK_2(Bug914Layer::onTouchesMoved, this);
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
|
||||
// ask director the the window size
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
LayerColor *layer;
|
||||
for( int i=0;i < 5;i++)
|
||||
{
|
||||
layer = LayerColor::create(Color4B(i*20, i*20, i*20,255));
|
||||
layer->setContentSize(Size(i*100, i*100));
|
||||
layer->setPosition(size.width/2, size.height/2);
|
||||
layer->setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
layer->ignoreAnchorPointForPosition(false);
|
||||
addChild(layer, -1-i);
|
||||
}
|
||||
|
||||
// create and initialize a Label
|
||||
auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 64.0f);
|
||||
auto item1 = MenuItemFont::create("restart", CC_CALLBACK_1(Bug914Layer::restart, this));
|
||||
|
||||
auto menu = Menu::create(item1, nullptr);
|
||||
menu->alignItemsVertically();
|
||||
menu->setPosition(size.width/2, 100);
|
||||
addChild(menu);
|
||||
|
||||
// position the label on the center of the screen
|
||||
label->setPosition(size.width /2 , size.height/2);
|
||||
|
||||
// add the label as a child to this Layer
|
||||
addChild(label);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bug914Layer::onTouchesMoved(const std::vector<Touch*>& touches, Event * event)
|
||||
{
|
||||
log("Number of touches: %d", (int)touches.size());
|
||||
}
|
||||
|
||||
void Bug914Layer::onTouchesBegan(const std::vector<Touch*>& touches, Event * event)
|
||||
{
|
||||
onTouchesMoved(touches, event);
|
||||
}
|
||||
|
||||
void Bug914Layer::restart(Ref* sender)
|
||||
{
|
||||
Director::getInstance()->replaceScene(Bug914Layer::create());
|
||||
}
|
||||
18
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-914.h
Normal file
18
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-914.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef __BUG_914_H__
|
||||
#define __BUG_914_H__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class Bug914Layer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
virtual bool init() override;
|
||||
|
||||
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
||||
void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
||||
void restart(cocos2d::Ref* sender);
|
||||
|
||||
CREATE_FUNC(Bug914Layer);
|
||||
};
|
||||
|
||||
#endif // __BUG_914_H__
|
||||
42
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-CCDrawNode.cpp
Normal file
42
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-CCDrawNode.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// CCDrawNode::onDrawGLPoint & CCDrawNode::onDrawGLLine miss
|
||||
// calling GL::blendFunc, so when a sprite set blendFunc, these
|
||||
// function will get a wrong result.
|
||||
// In this test, see a red line when bug resolved.
|
||||
//
|
||||
|
||||
#include "Bug-CCDrawNode.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool BugDrawNodeLayer::init()
|
||||
{
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
auto testSprite = Sprite::create("cocosui/CloseNormal.png");
|
||||
BlendFunc blend;
|
||||
blend.src = GL_ZERO;
|
||||
blend.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
testSprite->setBlendFunc(blend);
|
||||
testSprite->setPosition(Vec2(size.width / 2, size.height / 2));
|
||||
testSprite->setScale(10);
|
||||
addChild(testSprite);
|
||||
|
||||
auto drawNode = DrawNode::create();
|
||||
drawNode->drawLine(Vec2(0, 0), Vec2(size.width, size.height), Color4F(1, 0, 0, 0.5f));
|
||||
Vec2 point = Vec2(size.width / 2, size.height / 2);
|
||||
drawNode->drawPoint(point, 8, Color4F(1, 0, 0, 0.5f));
|
||||
addChild(drawNode);
|
||||
|
||||
auto label = Label::create();
|
||||
label->setString(std::string("If you see a red line with a block at center, the bug is fixed!"));
|
||||
label->setPosition(size.width / 2, size.height / 4);
|
||||
label->setTextColor(Color4B::ORANGE);
|
||||
addChild(label);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
14
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-CCDrawNode.h
Normal file
14
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-CCDrawNode.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __BUG_CCDRAWNODE_H__
|
||||
#define __BUG_CCDRAWNODE_H__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class BugDrawNodeLayer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(BugDrawNodeLayer);
|
||||
|
||||
virtual bool init() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
123
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-Child.cpp
Normal file
123
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-Child.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// Bug-Child.cpp
|
||||
// cocos2d_tests
|
||||
//
|
||||
// Created by NiTe Luo on 5/12/14.
|
||||
//
|
||||
//
|
||||
|
||||
#include "Bug-Child.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
bool BugChild::init()
|
||||
{
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
|
||||
// create and initialize a Label
|
||||
auto item1 = MenuItemFont::create("Switch Child", CC_CALLBACK_1(BugChild::switchChild, this));
|
||||
|
||||
menu = Menu::create(item1, nullptr);
|
||||
|
||||
menu->alignItemsVertically();
|
||||
menu->setPosition(size.width/2, 100);
|
||||
addChild(menu);
|
||||
|
||||
parent1 = Sprite::create("Images/grossini.png");
|
||||
parent1->setPosition(size.width/4, size.height/2);
|
||||
addChild(parent1);
|
||||
|
||||
parent2 = Sprite::create("Images/grossinis_sister1.png");
|
||||
parent2->setPosition(size.width*3/4, size.height/2);
|
||||
addChild(parent2);
|
||||
|
||||
child = Sprite::create("Images/grossinis_sister2.png");
|
||||
child->setPosition(20, 20);
|
||||
child->retain();
|
||||
parent1->addChild(child);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void BugChild::switchChild(Ref *sender)
|
||||
{
|
||||
if(parent1->getChildrenCount() > 0)
|
||||
{
|
||||
parent1->removeChild(child, false);
|
||||
parent2->addChild(child);
|
||||
CCLOG("Child attached to parent2");
|
||||
}
|
||||
else
|
||||
{
|
||||
parent2->removeChild(child, false);
|
||||
parent1->addChild(child);
|
||||
CCLOG("Child attached to parent1");
|
||||
}
|
||||
}
|
||||
|
||||
bool BugCameraMask::init()
|
||||
{
|
||||
if (!BugsTestBase::init()) return false;
|
||||
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
|
||||
auto node = Node::create();
|
||||
node->setPosition(size.width/4, size.height/3);
|
||||
_sprite = Sprite::create("Images/grossini.png");
|
||||
node->addChild(_sprite);
|
||||
node->setCameraMask((unsigned short)CameraFlag::USER1);
|
||||
auto move = MoveBy::create(2, Vec2(200,0));
|
||||
|
||||
node->runAction(RepeatForever::create(Sequence::createWithTwoActions(move, move->reverse())));
|
||||
addChild(node);
|
||||
|
||||
auto camera = Camera::create();
|
||||
camera->setCameraFlag(CameraFlag::USER1);
|
||||
addChild(camera);
|
||||
|
||||
|
||||
auto item1 = MenuItemFont::create("Switch Child", CC_CALLBACK_1(BugCameraMask::switchSpriteFlag, this));
|
||||
|
||||
auto menu = Menu::create(item1, nullptr);
|
||||
|
||||
menu->alignItemsVertically();
|
||||
menu->setPosition(size.width/2, 100);
|
||||
addChild(menu);
|
||||
|
||||
_spriteMaskLabel = Label::create();
|
||||
_spriteMaskLabel->setPosition(size.width/2, 120);
|
||||
addChild(_spriteMaskLabel);
|
||||
updateSpriteMaskLabel();
|
||||
|
||||
auto label = Label::create();
|
||||
label->setPosition(size.width/2, size.height * 0.9);
|
||||
label->setString("Sprite should always run action.");
|
||||
addChild(label);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BugCameraMask::switchSpriteFlag(Ref *sender)
|
||||
{
|
||||
if((unsigned short) CameraFlag::USER1 == _sprite->getCameraMask())
|
||||
{
|
||||
_sprite->setCameraMask((unsigned short)CameraFlag::DEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sprite->setCameraMask((unsigned short)CameraFlag::USER1);
|
||||
}
|
||||
|
||||
updateSpriteMaskLabel();
|
||||
}
|
||||
|
||||
void BugCameraMask::updateSpriteMaskLabel()
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream<<"The camera Mask is "<<(_sprite->getCameraMask() == 1 ? "CamereFlag::Default" : "CameraFlag::User1")<<std::endl;
|
||||
_spriteMaskLabel->setString(stream.str());
|
||||
}
|
||||
46
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-Child.h
Normal file
46
cocos2d/tests/cpp-tests/Classes/BugsTest/Bug-Child.h
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// Bug-Child.h
|
||||
// cocos2d_tests
|
||||
//
|
||||
// Created by NiTe Luo on 5/12/14.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef __Bug_Child__
|
||||
#define __Bug_Child__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class BugChild : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(BugChild);
|
||||
|
||||
virtual bool init() override;
|
||||
|
||||
void switchChild(cocos2d::Ref* sender);
|
||||
|
||||
protected:
|
||||
|
||||
cocos2d::Sprite* parent1;
|
||||
cocos2d::Sprite* parent2;
|
||||
|
||||
cocos2d::Sprite* child;
|
||||
|
||||
cocos2d::Menu* menu;
|
||||
};
|
||||
|
||||
class BugCameraMask : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(BugCameraMask);
|
||||
|
||||
virtual bool init() override;
|
||||
|
||||
void switchSpriteFlag(cocos2d::Ref* sender);
|
||||
void updateSpriteMaskLabel();
|
||||
Node* _sprite;
|
||||
cocos2d::Label* _spriteMaskLabel;
|
||||
};
|
||||
|
||||
#endif /* defined(__Bug_Child__) */
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// When a pageview set to relative position & size, if it
|
||||
// has child widget set to relative position & size either,
|
||||
// when change layer size, relayout won't correctly effect
|
||||
// to the child.
|
||||
// In this test, if button at the center of panel, bug is fixed!
|
||||
//
|
||||
|
||||
#include "Bug-PageViewLayout.h"
|
||||
#include "cocostudio/CocoStudio.h"
|
||||
#include "ui/CocosGUI.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
USING_NS_CC;
|
||||
using namespace ui;
|
||||
|
||||
bool BugPageViewLayer::init()
|
||||
{
|
||||
if (BugsTestBase::init())
|
||||
{
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
|
||||
FileUtils::getInstance()->addSearchPath("ccs-res/cocosui/CustomTest/CustomWidgetCallbackBindTest");
|
||||
auto rootNode = CSLoader::createNode("cocosui/CustomTest/CustomWidgetCallbackBindTest/PageViewBugScene.csb");
|
||||
auto child = rootNode->getChildByName("ProjectNode_1");
|
||||
child->setContentSize(Size(480, 320));
|
||||
Helper::doLayout(child);
|
||||
addChild(rootNode);
|
||||
|
||||
auto label = Label::create();
|
||||
label->setString(std::string("If button is at the center of panel, the bug is fixed!"));
|
||||
label->setPosition(size.width / 2, size.height / 4);
|
||||
label->setTextColor(Color4B::ORANGE);
|
||||
this->addChild(label);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef __BUG_PAGEVIEWLAYOUT_H__
|
||||
#define __BUG_PAGEVIEWLAYOUT_H__
|
||||
|
||||
#include "BugsTest.h"
|
||||
|
||||
class BugPageViewLayer : public BugsTestBase
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(BugPageViewLayer);
|
||||
|
||||
virtual bool init() override;
|
||||
};
|
||||
|
||||
#endif // !__BUG_PAGEVIEWLAYOUT_H__
|
||||
40
cocos2d/tests/cpp-tests/Classes/BugsTest/BugsTest.cpp
Normal file
40
cocos2d/tests/cpp-tests/Classes/BugsTest/BugsTest.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "BugsTest.h"
|
||||
#include "Bug-350.h"
|
||||
#include "Bug-422.h"
|
||||
#include "Bug-458/Bug-458.h"
|
||||
#include "Bug-624.h"
|
||||
#include "Bug-886.h"
|
||||
#include "Bug-899.h"
|
||||
#include "Bug-914.h"
|
||||
#include "Bug-1159.h"
|
||||
#include "Bug-1174.h"
|
||||
#include "Bug-12847.h"
|
||||
#include "Bug-Child.h"
|
||||
#include "Bug-CCDrawNode.h"
|
||||
#include "Bug-PageViewLayout.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
#include "Bug-14327.h"
|
||||
#endif
|
||||
|
||||
BugsTests::BugsTests()
|
||||
{
|
||||
ADD_TEST_CASE(Bug350Layer);
|
||||
ADD_TEST_CASE(Bug422Layer);
|
||||
ADD_TEST_CASE(Bug458Layer);
|
||||
ADD_TEST_CASE(Bug624Layer);
|
||||
ADD_TEST_CASE(Bug886Layer);
|
||||
ADD_TEST_CASE(Bug899Layer);
|
||||
ADD_TEST_CASE(Bug914Layer);
|
||||
ADD_TEST_CASE(Bug1159Layer);
|
||||
ADD_TEST_CASE(Bug1174Layer);
|
||||
ADD_TEST_CASE(BugChild);
|
||||
ADD_TEST_CASE(BugCameraMask);
|
||||
ADD_TEST_CASE(BugDrawNodeLayer);
|
||||
ADD_TEST_CASE(BugPageViewLayer);
|
||||
ADD_TEST_CASE(Bug12847Layer);
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
ADD_TEST_CASE(Bug14327Layer);
|
||||
#endif
|
||||
}
|
||||
14
cocos2d/tests/cpp-tests/Classes/BugsTest/BugsTest.h
Normal file
14
cocos2d/tests/cpp-tests/Classes/BugsTest/BugsTest.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __BUGS_TEST_H__
|
||||
#define __BUGS_TEST_H__
|
||||
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class BugsTestBase : public TestCase
|
||||
{
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
DEFINE_TEST_SUITE(BugsTests);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user