本文整理汇总了C++中Paddle::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Paddle::setPosition方法的具体用法?C++ Paddle::setPosition怎么用?C++ Paddle::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paddle
的用法示例。
在下文中一共展示了Paddle::setPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createPaddles
void createPaddles()
{
player_one.setLength(3);
player_one.setPosition(rows/2 - 2, columns - 1);
for(int i = 0; i < player_one.length; i++)
{
board[player_one.x_position + i][player_one.y_position] = '|';
}
player_two.setLength(3);
player_two.setPosition(rows/2 - 2, 0);
for(int i = 0; i < player_two.length; i++)
{
board[player_two.x_position + i][player_two.y_position] = '|';
}
}
示例2: CGPointMake
//------------------------------------------------------------------
//
// PongLayer
//
//------------------------------------------------------------------
PongLayer::PongLayer()
{
m_ballStartingVelocity = CGPointMake(20.0f, -100.0f);
m_ball = Ball::ballWithTexture( CCTextureCache::sharedTextureCache()->addImage(s_Ball) );
m_ball->setPosition( CGPointMake(160.0f, 240.0f) );
m_ball->setVelocity( m_ballStartingVelocity );
addChild( m_ball );
m_ball->retain();
CCTexture2D* paddleTexture = CCTextureCache::sharedTextureCache()->addImage(s_Paddle);
NSMutableArray<NSObject *> *paddlesM = new NSMutableArray<NSObject *>(4);
Paddle* paddle = Paddle::paddleWithTexture(paddleTexture);
paddle->setPosition( CGPointMake(160, 15) );
paddlesM->addObject( paddle );
paddle = Paddle::paddleWithTexture( paddleTexture );
paddle->setPosition( CGPointMake(160, 480 - kStatusBarHeight - 15) );
paddlesM->addObject( paddle );
paddle = Paddle::paddleWithTexture( paddleTexture );
paddle->setPosition( CGPointMake(160, 100) );
paddlesM->addObject( paddle );
paddle = Paddle::paddleWithTexture( paddleTexture );
paddle->setPosition( CGPointMake(160, 480 - kStatusBarHeight - 100) );
paddlesM->addObject( paddle );
m_paddles = paddlesM->copy();
NSMutableArray<NSObject *>::NSMutableArrayIterator it;
for(it = m_paddles->begin(); it != m_paddles->end(); it++)
{
paddle = (Paddle*)(*it);
if(!paddle)
break;
addChild(paddle);
}
paddlesM->release();
schedule( schedule_selector(PongLayer::doStep) );
}
示例3: Point
//------------------------------------------------------------------
//
// PongLayer
//
//------------------------------------------------------------------
PongLayer::PongLayer()
{
_ballStartingVelocity = Point(20.0f, -100.0f);
_ball = Ball::ballWithTexture( TextureCache::getInstance()->addImage(s_Ball) );
_ball->setPosition( VisibleRect::center() );
_ball->setVelocity( _ballStartingVelocity );
addChild( _ball );
_ball->retain();
Texture2D* paddleTexture = TextureCache::getInstance()->addImage(s_Paddle);
Array *paddlesM = Array::createWithCapacity(4);
Paddle* paddle = Paddle::createWithTexture(paddleTexture);
paddle->setPosition( Point(VisibleRect::center().x, VisibleRect::bottom().y + 15) );
paddlesM->addObject( paddle );
paddle = Paddle::createWithTexture( paddleTexture );
paddle->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - kStatusBarHeight - 15) );
paddlesM->addObject( paddle );
paddle = Paddle::createWithTexture( paddleTexture );
paddle->setPosition( Point(VisibleRect::center().x, VisibleRect::bottom().y + 100) );
paddlesM->addObject( paddle );
paddle = Paddle::createWithTexture( paddleTexture );
paddle->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - kStatusBarHeight - 100) );
paddlesM->addObject( paddle );
_paddles = paddlesM->clone();
_paddles->retain();
Object* pObj = NULL;
CCARRAY_FOREACH(_paddles, pObj)
{
paddle = static_cast<Paddle*>(pObj);
if(!paddle)
break;
addChild(paddle);
}
示例4: init
bool ChoiceScene::init()
{
if (!Layer::init())
{
return false;
}
Size szWin = Director::getInstance()->getWinSize();
Sprite *pSprite = Sprite::create("Black.png");
Size szSprite = pSprite->getContentSize();
pSprite->setScaleX(szWin.width / szSprite.width);
pSprite->setScaleY(szWin.height / szSprite.height);
pSprite->setPosition(Point(szWin.width / 2, szWin.height / 2));
this->addChild(pSprite, 0);
const char *szImgs[4] =
{
"paddle/btn_play.png",
"paddle/btn_rewind.png",
"paddle/btn_fast_forward.png",
"fonts/fps_images.png" };
float fSettings[4][4] =
{
{
20.0f / 480,
16.0f / 320,
280.0f / 480,
160.0f / 320 },
{
20.0f / 480,
16.0f / 320,
200.0f / 480,
160.0f / 320 },
{
20.0f / 480,
16.0f / 320,
240.0f / 480,
160.0f / 320 },
{
20.0f / 480,
22.0f / 320,
280.0f / 480,
172.0f / 320 } };
// enum_evt evts[4] =
// {
// evt_start,
// evt_pressA,
// evt_pressB,
// evt_text };
for (int i = 0; i < 3; ++i)
{
float* fSetting = fSettings[i];
Texture2D* paddleTexture = Director::getInstance()->getTextureCache()->addImage(szImgs[i]);
Paddle* pPaddle = Paddle::paddleWithTexture(paddleTexture);
Size szBtn = pPaddle->getContentSize();
pPaddle->setScaleX(szWin.width / szBtn.width * fSetting[0]);
pPaddle->setScaleY(szWin.height / szBtn.height * fSetting[1]);
pPaddle->setPosition(Point(szWin.width * fSetting[2], szWin.height * fSetting[3]));
pPaddle->setTag(i);
pPaddle->onAction = CC_CALLBACK_1(ChoiceScene::touchAction,this);
pPaddle->setLongTouch(false);
addChild(pPaddle);
//pPaddle->setpSence(this);
//pPaddle->setevttyp(evts[i]);
}
int i = 3;
Color3B color =
{
0,
0,
0 };
float* fSetting = fSettings[i];
LabelAtlas* label1 = LabelAtlas::create("1", szImgs[i], 16, 32, '.');
Size sz = label1->getContentSize();
label1->setAnchorPoint(Point(0.5f, 0.5f));
label1->setScaleX(szWin.width / sz.width * fSetting[0]);
label1->setScaleY(szWin.height / sz.height * fSetting[1]);
label1->setPosition(Point(szWin.width * fSetting[2], szWin.height * fSetting[3]));
label1->setColor(color);
label1->updateAtlasValues();
//updateAtlasValues
// addChild(label1, 0, evt_text);
addChild(label1, 0, 4);
//this->scheduleUpdate();
log("updat11e");
return true;
}