本文整理汇总了C++中Color4F函数的典型用法代码示例。如果您正苦于以下问题:C++ Color4F函数的具体用法?C++ Color4F怎么用?C++ Color4F使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Color4F函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Size
void CameraFrameBufferTest::onEnter()
{
auto sizeInpixels = Director::getInstance()->getWinSizeInPixels();
auto size = Director::getInstance()->getWinSize();
auto fboSize = Size(sizeInpixels.width * 1, sizeInpixels.height * 1.5);
auto fbo = experimental::FrameBuffer::create(1, fboSize.width, fboSize.height);
CameraBaseTest::onEnter();
//auto sprite = Sprite::createWithTexture(fbo);
//sprite->setPosition(Vec2(100,100));
//std::string filename = "Sprite3DTest/girl.c3b";
//auto sprite = Sprite3D::create(filename);
//sprite->setScale(1.0);
//auto animation = Animation3D::create(filename);
//if (animation)
//{
// auto animate = Animate3D::create(animation);
// sprite->runAction(RepeatForever::create(animate));
//}
//sprite->setPosition(Vec2(100,100));
auto rt = experimental::RenderTarget::create(fboSize.width, fboSize.height);
auto rtDS = experimental::RenderTargetDepthStencil::create(fboSize.width, fboSize.height);
fbo->attachRenderTarget(rt);
fbo->attachDepthStencilTarget(rtDS);
auto sprite = Sprite::createWithTexture(fbo->getRenderTarget()->getTexture());
sprite->setScale(0.3);
sprite->runAction(RepeatForever::create(RotateBy::create(1, 90)));
sprite->setPosition(size.width/2, size.height/2);
addChild(sprite);
auto sprite2 = Sprite::create(s_pathGrossini);
sprite2->setPosition(Vec2(size.width/5,size.height/5));
addChild(sprite2);
sprite2->setCameraMask((unsigned short)CameraFlag::USER1);
auto move = MoveBy::create(1.0, Vec2(100,100));
sprite2->runAction(
RepeatForever::create(
Sequence::createWithTwoActions(
move, move->reverse())
)
);
auto camera = Camera::create();
camera->setCameraFlag(CameraFlag::USER1);
camera->setDepth(-1);
camera->setFrameBufferObject(fbo);
fbo->setClearColor(Color4F(1,1,1,1));
addChild(camera);
}
示例2: b2Vec2
void LHBox2dDebug::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color)
{
const float32 k_segments = 16.0f;
int vertexCount=16;
const float32 k_increment = 2.0f * b2_pi / k_segments;
float32 theta = 0.0f;
Vec2* vertices = new Vec2[vertexCount];
for (int32 i = 0; i < k_segments; ++i)
{
b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta));
vertices[i] = Vec2(v.x*mRatio, v.y*mRatio);
theta += k_increment;
}
Color4F fillColor = Color4F(color.r, color.g, color.b, 0.5);
Color4F borderColor = Color4F(color.r, color.g, color.b, 1);
drawNode->drawPolygon(vertices, vertexCount, fillColor, 1, borderColor);
delete[] vertices;
}
示例3: Color4F
bool GamePanel::onTouchBegan(Touch* touch, Event* event){
//CALCULATION
startLoc = touch->getLocation();
//DRAW BEGIN POINT
pen->drawSolidCircle(startLoc, 70.0f, 0.0f, 100, Color4F(1, 0, 0, 0.1f));
//PLAYER CHANGE SPRITE
player->readyToJump(Vec2(0, 0));
//DEBUG*
auto para = player->getParent()->getParent();
char str[100] = { 0 };
sprintf(str, "Began: (%d, %d) %s", (int)(startLoc.x), (int)(startLoc.y), para->getName().c_str());
debugLabel->setString(str);
return true;
}
示例4: srand
bool UT_Map::init(){
if(!Layer::init()){
return false;
}
//seeds the random number generator
srand((unsigned int)time(nullptr));
visibleSize = Director::getInstance()->getVisibleSize();
origin = Director::getInstance()->getVisibleOrigin();
//create wall
//If Full Paint FPS Droped to 12
//
test_map = new GameMap();
test_map->BuildMap("res/map/block_01.jpg" , Size(18, 10), (int)PhysicsCategory::Wall, (int)PhysicsCategory::None, (int)PhysicsCategory::Player);
this->addChild(test_map);
log("GetPlayerPos() ? (%f, %f)",test_map->GetPlayerPos().x , test_map->GetPlayerPos().y);
//create wall crasher
if(true){
body = cocos2d::DrawNode::create();
body->drawSolidRect(Vec2(0,0), Vec2(10,25), Color4F(0.1, 0, 1, 1));
body->setPosition(test_map->GetPlayerPos());
test_map->addChild(body);
body->setName("Player_body");
body->setZOrder(1);
auto body_phyBody = PhysicsBody::createBox(Size(body->getContentSize().width , body->getContentSize().height),PhysicsMaterial(0.1f, 1.0f, 0.0f));
body_phyBody->setDynamic(true);
body_phyBody->setCategoryBitmask((int)PhysicsCategory::Player);
body_phyBody->setCollisionBitmask((int)PhysicsCategory::None);
body_phyBody->setContactTestBitmask((int)PhysicsCategory::Wall);
body->setPhysicsBody(body_phyBody);
}
this->schedule(schedule_selector(UT_Map::Scheduler));
//Set the Physics Collision notification
auto contactListener = EventListenerPhysicsContact::create();
contactListener->onContactBegin = CC_CALLBACK_1(UT_Map::onContactBegan, this);
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(contactListener, this);
return true;
}
示例5: Vec2
void taskMgr::ShowMainTask(PMission task)
{
if(m_openMain||m_openSaml)
{
return;
}
m_openMain = true;
maskLayer = DrawNode::create();
maskLayer->drawSolidRect(Vec2(-7000, -7000), Vec2(7000, 7000), Color4F(0, 0, 0, 0.6));
G_MainGame->m_UILayer->addChild(maskLayer, 99);
AddBg(0,task);
auto btnClose = MenuItemImage::create("ccb/ccbResources/common/close.png","ccb/ccbResources/common/close.png",[&](Ref* Sender){
BUBBLE;
this->CloseMissInfo();
});
Menu *menu;
MenuItemImage *m_btn;
Sprite* getBtnPic=Sprite::create();
if(task->missState != task->missNeed)
{
// no com
m_btn = MenuItemImage::create("ccb/ccbResources/common/lButton_down.png","",[&](Ref* Sender){
});
getBtnPic->setTexture("images/Word/get_award_gray.png");
}
else
{
m_btn = MenuItemImage::create("ccb/ccbResources/common/lButton_up.png","",[=](Ref* Sender){
LoseMission(0);
if(task->rewardType == 0)
{
Player::getInstance()->AddGold(task->rewardnum);
}
task->missState = 999999;
this->CloseMissInfo();
});
getBtnPic->setTexture("images/Word/get_award.png");
}
menu = Menu::create(btnClose,m_btn,nullptr);
m_ui->addChild(menu);
m_ui->addChild(getBtnPic);
menu->setPosition(0,0);
btnClose->setPosition(Vec2(210, 180));
m_btn->setPosition(Vec2(0, -150));
getBtnPic->setPosition(Vec2(0, -150));
}
示例6: _clearColor
FrameBuffer::FrameBuffer()
: _clearColor(Color4F(0, 0, 0, 1))
, _clearDepth(1.0)
, _clearStencil(0)
, _fbo(0)
, _rt(nullptr)
, _rtDepthStencil(nullptr)
, _fboBindingDirty(true)
, _isDefault(false)
#if CC_ENABLE_CACHE_TEXTURE_DATA
, _dirtyFBOListener(nullptr)
#endif
{
_frameBuffers.insert(this);
}
示例7: getContentSize
void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
AtlasNode::draw(renderer, transform, transformUpdated);
_debugDrawNode->clear();
auto size = getContentSize();
Vec2 vertices[4]=
{
Vec2::ZERO,
Vec2(size.width, 0),
Vec2(size.width, size.height),
Vec2(0, size.height)
};
_debugDrawNode->drawPoly(vertices, 4, true, Color4F(1.0, 1.0, 1.0, 1.0));
}
示例8: addChild
bool Lander::init()
{
if (!Node::init())
{
return false;
}
_landerBody = DrawNode::create();
addChild(_landerBody);
Vec2 landerVecs[] = {
Vec2(-20, 0),
Vec2(-15, 10),
Vec2(-13, 10),
Vec2(-10, 15),
Vec2(10, 15),
Vec2(13, 10),
Vec2(15, 10),
Vec2(20, 0),
};
_landerBody->drawPoly(landerVecs, 8, true, Color4F(1.f, 0.f, 1.f, 1.f));
_fire = DrawNode::create();
addChild(_fire);
_fire->drawTriangle(Vec2(-6, 0), Vec2(6, 0), Vec2(0, -8), Color4F(1.f, 1.f, 0.f, 0.5f));
_fire->setVisible(false);
_fitnessScore = -999999.f;
_velocity = Vec2::ZERO;
_actionFlag = NONE;
_mass = LANDER_MASS;
_tickCount = 0;
_bLandOver = false;
_bLandOK = false;
_bCtrlByHuman = false;
return true;;
}
示例9: Vec2
void PauseLayer::AddSpriteBorder(MenuItemImage *sp)
{
auto drawNode = DrawNode::create();
auto p = sp->getPosition();
Size s = Director::getInstance()->getVisibleSize();
Vec2 ps[4] =
{
Vec2(p.x - s.width*0.13, p.y - s.height*0.04),
Vec2(p.x + s.width*0.13, p.y - s.height*0.04),
Vec2(p.x + s.width*0.13, p.y + s.height*0.04),
Vec2(p.x - s.width*0.13, p.y + s.height*0.04),
};
drawNode->drawPoly(ps, 4, true, Color4F(1.0, 1.0, 1.0, 1.0));
this->addChild(drawNode);
}
示例10: while
Color4F HelloWorld::randomBrightColor()
{
while (true) {
float requiredBrightness = 192;
Color4B randomColor =
Color4B(rand() % 255,
rand() % 255,
rand() % 255,
255);
if (randomColor.r > requiredBrightness ||
randomColor.g > requiredBrightness ||
randomColor.b > requiredBrightness) {
return Color4F(randomColor);
}
}
}
示例11: Color4F
void OBBTest::update(float dt)
{
if (_pick)
return;
_drawAABB->clear();
Mat4 mat = Mat4::IDENTITY;
mat.rotate(Vec3::UNIT_Y, 0.01f);
_obb.transform(mat);
Vec3 corners[8] = {};
_obb.getCorners(corners);
_drawAABB->setPosition3D(_obb._center);
_drawAABB->drawCube(corners, Color4F(0,0,1,1));
}
示例12: Color4F
void Player::update(float delta)
{
auto c = Coordinate::getInstance();
this->velocity.y += this->acceleration * this->direction;
this->point += this->velocity;
this->prevPoints.push_back(this->point);
if (this->prevPoints.size() > 50) this->prevPoints.pop_front();
int i = 0;
for (auto p : this->prevPoints) {
this->raw_points[i++] = c->logical2physical(p);
}
this->node->clear();
this->node->drawPoly(this->raw_points, (unsigned)this->prevPoints.size(), false, Color4F(1, 1, 1, 1));
}
示例13: setClearColor
void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags)
{
setClearColor(Color4F(r, g, b, a));
setClearDepth(depthValue);
setClearStencil(stencilValue);
setClearFlags(flags);
this->begin();
//clear screen
_beginWithClearCommand.init(_globalZOrder);
_beginWithClearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this);
Director::getInstance()->getRenderer()->addCommand(&_beginWithClearCommand);
}
示例14: _Zorder
Node::Node() :
_Zorder(0),
_pParent(nullptr),
_Pos(Point::ZERO),
_AnchorPoint(Point::ANCHOR_MIDDLE),
_Center(Point::ZERO),
_Scale(Point(1, 1)),
_CollisionRect(Rect(0, 0, 0, 0)),
_Size(Size::ZERO),
_Color4F(Color4F(254, 254, 254, 254)),
_d3dColor(D3DCOLOR_RGBA(254,254,254,254)),
_RotAngle(0),
_Visible(true)//,
//_IsRunningAction(false)
{
_ChildPool.reserve(5);
}
示例15: kmGLMatrixMode
void ClippingNode::drawFullScreenQuadClearStencil()
{
kmGLMatrixMode(KM_GL_MODELVIEW);
kmGLPushMatrix();
kmGLLoadIdentity();
kmGLMatrixMode(KM_GL_PROJECTION);
kmGLPushMatrix();
kmGLLoadIdentity();
DrawPrimitives::drawSolidRect(Point(-1,-1), Point(1,1), Color4F(1, 1, 1, 1));
kmGLMatrixMode(KM_GL_PROJECTION);
kmGLPopMatrix();
kmGLMatrixMode(KM_GL_MODELVIEW);
kmGLPopMatrix();
}