2011-07-08 11:22:35 +08:00
|
|
|
//
|
|
|
|
// 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"
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* Bug1159Layer::scene()
|
2011-07-08 11:22:35 +08:00
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto scene = Scene::create();
|
|
|
|
auto layer = Bug1159Layer::create();
|
2013-07-23 08:25:44 +08:00
|
|
|
scene->addChild(layer);
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2013-07-23 08:25:44 +08:00
|
|
|
return scene;
|
2011-07-08 11:22:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Bug1159Layer::init()
|
|
|
|
{
|
|
|
|
if (BugsTestBaseLayer::init())
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->setDepthTest(true);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto background = LayerColor::create(Color4B(255, 0, 255, 255));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(background);
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite_a = LayerColor::create(Color4B(255, 0, 0, 255), 700, 700);
|
2014-05-15 01:07:09 +08:00
|
|
|
sprite_a->setAnchorPoint(Vec2(0.5f, 0.5f));
|
2012-06-15 15:10:40 +08:00
|
|
|
sprite_a->ignoreAnchorPointForPosition(false);
|
2014-08-28 11:41:18 +08:00
|
|
|
sprite_a->setPosition(0.0f, s.height/2);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite_a);
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
sprite_a->runAction(RepeatForever::create(Sequence::create(
|
2014-05-15 01:07:09 +08:00
|
|
|
MoveTo::create(1.0f, Vec2(1024.0f, 384.0f)),
|
|
|
|
MoveTo::create(1.0f, Vec2(0.0f, 384.0f)),
|
2014-07-10 00:45:27 +08:00
|
|
|
nullptr)));
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite_b = LayerColor::create(Color4B(0, 0, 255, 255), 400, 400);
|
2014-05-15 01:07:09 +08:00
|
|
|
sprite_b->setAnchorPoint(Vec2(0.5f, 0.5f));
|
2012-06-15 15:10:40 +08:00
|
|
|
sprite_b->ignoreAnchorPointForPosition(false);
|
2014-08-28 11:41:18 +08:00
|
|
|
sprite_b->setPosition(s.width/2, s.height/2);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite_b);
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label = MenuItemLabel::create(Label::createWithSystemFont("Flip Me", "Helvetica", 24), CC_CALLBACK_1(Bug1159Layer::callBack, this) );
|
2014-07-10 00:45:27 +08:00
|
|
|
auto menu = Menu::create(label, nullptr);
|
2014-08-28 11:41:18 +08:00
|
|
|
menu->setPosition(s.width - 200.0f, 50.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(menu);
|
2011-07-08 11:22:35 +08:00
|
|
|
|
|
|
|
return true;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return false;
|
2011-07-08 11:22:35 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void Bug1159Layer::callBack(Ref* sender)
|
2011-07-08 11:22:35 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(TransitionPageTurn::create(1.0f, Bug1159Layer::scene(), false));
|
2011-07-08 11:22:35 +08:00
|
|
|
}
|
2012-06-26 11:09:37 +08:00
|
|
|
|
|
|
|
void Bug1159Layer::onExit()
|
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->setDepthTest(false);
|
2012-10-31 11:33:53 +08:00
|
|
|
BugsTestBaseLayer::onExit();
|
2012-06-26 11:09:37 +08:00
|
|
|
}
|