本文整理汇总了C++中AnimatedSprite::update方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimatedSprite::update方法的具体用法?C++ AnimatedSprite::update怎么用?C++ AnimatedSprite::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnimatedSprite
的用法示例。
在下文中一共展示了AnimatedSprite::update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Senario::update(float time)
{
if(animatedStringList != NULL)
{
for (int i = 0; i < animatedStringList->count(); i++)
{
AnimatedString* as = (AnimatedString*) animatedStringList->objectAtIndex(i);
as->update(time);
}
}
if(animatedSpriteList != NULL)
{
for (int i = 0; i < animatedSpriteList->count(); i++)
{
AnimatedSprite* as = (AnimatedSprite*) animatedSpriteList->objectAtIndex(i);
as->update(time);
}
}
if(animatedDialogueList != NULL)
{
for (int i = 0; i < animatedDialogueList->count(); i++)
{
AnimatedDialogue* ad = (AnimatedDialogue*) animatedDialogueList->objectAtIndex(i);
ad->update(time);
}
}
}
示例2: update
void pacman::update(){
xpos += xvel;
ypos += yvel;
sprite.setPosition(sf::Vector2f(xpos, ypos));
anspr.setPosition(sf::Vector2f(xpos, ypos));
collision_box = anspr.getGlobalBounds();
anspr.update(frame_time.restart());
}
示例3: update
void update(sf::Time time)
{
MusicManager::instance().update(time);
system.update(time);
sm.update();
oTweener.step(time.asMilliseconds() / 1000.f);
if ((int)(rand() % 90) == 3 && first) sm.setCurrentEffect("distortion", sf::seconds(0.05));
if ((int)(rand() % 100) == 3 && !first) sm.setCurrentEffect("inversion", sf::seconds(1));
if (first)
{
logo.setColor(sf::Color(255,255,255,interpolateLinear(logo.getColor().a, 255, 0.05f)));
logo.setPosition(0, newLogoY);
if (!pressFading)
{
press.setColor(sf::Color(255,255,255,interpolateLinear(press.getColor().a, 0,pressFactor)));
if (press.getColor().a < 7)
{
pressFading = true;
}
}
else
{
press.setColor(sf::Color(255,255,255,interpolateLinear(press.getColor().a, 255, pressFactor)));
if (press.getColor().a > 243)
{
pressFading = false;
}
}
sprite.update(time);
if (transition && timer.getElapsedTime().asSeconds() > 0.5)
{
press.setColor(sf::Color(255,255,255,0));
}
if (transition && timer.getElapsedTime().asSeconds() > 0.5)
{
transition = false;
oTweener.addTween(&CDBTweener::TWEQ_BACK, CDBTweener::TWEA_INOUT, 2.f, &newLogoY, -800.0f);
}
if (!transition && logo.getPosition().y <= -800 && !check)
{
sm.setCurrentEffect("rgb", sf::seconds(1));
check = true;
timer.restart();SoundManager::instance().playNoiseSound();
}
if (check && timer.getElapsedTime().asSeconds() > 1)
{
first = false;
MusicManager::instance().playMusicFast("battle");
pressFading = true;
}
}
else
{
pressFactor = 0.2;
if (!pressFading)
{
pointer.setColor(sf::Color(255,255,255,interpolateLinear(pointer.getColor().a, 0,pressFactor)));
if (pointer.getColor().a < 7)
{
pressFading = true;
}
}
else
{
pointer.setColor(sf::Color(255,255,255,interpolateLinear(pointer.getColor().a, 255, pressFactor)));
if (pointer.getColor().a > 243)
{
pressFading = false;
}
}
switch (selection)
{
case 0:
pointer.setPosition(1183, 415);
break;
case 1:
pointer.setPosition(1183, 531);
break;
case 2:
pointer.setPosition(1183, 645);
break;
default:
break;
}
}
};
示例4: main
//.........这里部分代码省略.........
{
movement.y += speed;
noKeyWasPressed = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
currentAnimation = &walkingAnimationLeft;
movement.x -= speed;
noKeyWasPressed = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
currentAnimation = &walkingAnimationRight;
movement.x += speed;
noKeyWasPressed = false;
}
PlayerImage.play(*currentAnimation);
PlayerImage.move(movement * frameTime.asSeconds());
// if no key was pressed stop the animation
if (noKeyWasPressed)
{
//PlayerImage.stop();
PlayerImage.setFrameTime(sf::seconds(0.4));
currentAnimation = &walkingAnimationIdle;
}
if (!noKeyWasPressed) {
PlayerImage.setFrameTime(sf::seconds(0.1));
}
noKeyWasPressed = true;
// update AnimatedSprite
PlayerImage.update(frameTime);
// constatly check if the player completed the quest
playerQuests->checkQuests(draggeditem, playerInventory, PlayerImage);
window.clear();
if (loadedLevel) {
// draw the level background
window.draw(loadedLevel->bgSprite);
}
// draw the menubackground (bottom part of screen)
window.draw(MenuBackground);
for (auto && entity : loadedLevel->currentEntities) {
// draw all active entities in the level
window.draw(entity.Sprite);
}
// Show text of talking NPCs
if (playerQuests->triggerShowText) {
if (playerQuests->clock.getElapsedTime().asSeconds() < 10)
window.draw(playerQuests->talkText);
if (playerQuests->clock.getElapsedTime().asSeconds() > 10)
playerQuests->triggerShowText = false;
}
window.draw(PlayerImage);
window.draw(playerQuests->currentQuestText);
示例5: GameUpdateDraw
void GameUpdateDraw( NimblePixMap& map, NimbleRequest request ) {
#if WRITING_DOCUMENTATION
new(&TheMap) NimblePixMap( map );
#endif /* WRITING_DOCUMENTATION */
WavefieldRect = NimbleRect(PanelWidth,map.height()/2,map.width(),map.height());
NimblePixMap subsurface(map,WavefieldRect);
NimblePixMap seismogramClip( map,NimbleRect(PanelWidth,0,map.width(),map.height()/2) );
if( request & NimbleUpdate ) {
ShowGeology.update();
ShowSeismic.update();
}
const NimbleRequest pausedRequest = IsPaused ? request-NimbleUpdate : request;
SeismogramUpdateDraw( seismogramClip, pausedRequest&NimbleUpdate, TheColorFunc, IsAutoGainOn );
WavefieldFunctor wf(subsurface, pausedRequest);
SeismogramFunctor sf( seismogramClip, pausedRequest&NimbleDraw );
ReservoirFunctor rf( pausedRequest );
#if PARALLEL
tbb::parallel_invoke( wf, sf, rf );
#else
wf();
sf();
rf();
#endif
if( pausedRequest & NimbleUpdate ) {
DrillBit.update();
UpdateDuckAndRig();
}
if( request & NimbleDraw ) {
ClickableSetEnd = ClickableSet;
const int wavefieldWidth = map.width()-PanelWidth;
Assert(wavefieldWidth%4==0);
const int wavefieldHeight = map.height()/2;
ReservoirDrawHoles( subsurface );
if( DrillY>0 )
DrillBit.drawOn( subsurface, RigX-DrillBit.width()/2, DrillY-5 );
if( ShowReservoir )
ReservoirDraw( subsurface );
NimblePixMap spriteClip( map, NimbleRect( PanelWidth, 0, map.width(), map.height() ));\
NimblePixel greenPixel = map.pixel( NimbleColor( 0, NimbleColor::FULL, 0 ));
NimblePixel redPixel = map.pixel( NimbleColor( NimbleColor::FULL, 0, 0 ));
const int lineHeight = map.height()/2-1;
if( CultureBeginX<CultureEndX ) {
spriteClip.draw( NimbleRect( 0, lineHeight, CultureBeginX, lineHeight+1 ), greenPixel );
spriteClip.draw( NimbleRect( CultureBeginX, lineHeight-1, CultureEndX, lineHeight+2 ), redPixel );
spriteClip.draw( NimbleRect( CultureEndX, lineHeight, spriteClip.width(), lineHeight+1 ), greenPixel );
Culture.drawOn( spriteClip, CultureBeginX+(CultureEndX-CultureBeginX)/2-Culture.width()/2, map.height()/2-Culture.height() );
} else {
spriteClip.draw( NimbleRect( 0, lineHeight, spriteClip.width(), lineHeight+1 ), greenPixel );
}
OilRig->drawOn( spriteClip, RigX-OilRig->width()/2, OilRigVerticalOffset );
if( DuckGoingLeft )
DuckLeft.drawOn( spriteClip, DuckX-50, map.height()/2-DuckLeft.height()+12 );
else
DuckRight.drawOn( spriteClip, DuckX-(DuckRight.width()-50), map.height()/2-DuckLeft.height()+12 );
NimblePixMap panelClip( map, NimbleRect( 0, 0, PanelWidth, map.height() ));
PanelBackground.drawOn( panelClip );
int cashMeterY = map.height()- 50 -CashMeter.height();
int levelMeterY = cashMeterY - 10 - LevelMeter.height();
// The Min is there so that if there is room, the green line artistically lines up
// with the top of the fluid meters.
int fluidMeterY = Min(levelMeterY - 10 - WaterMeter.height(), map.height()/2 );
if( ScoreState.isDisplayingScore() ) {
LevelMeter.drawOn( map, PanelWidth/2-LevelMeter.width()/2, levelMeterY );
CashMeter.drawOn( map, PanelWidth/2-CashMeter.width()/2, cashMeterY );
}
int meterMarginX = (PanelWidth-WaterMeter.width()-OilMeter.width()-GasMeter.width())/4;
WaterMeter.drawOn( map, meterMarginX, fluidMeterY );
OilMeter.drawOn( map, PanelWidth/2-OilMeter.width()/2, fluidMeterY );
GasMeter.drawOn( map, PanelWidth-meterMarginX-GasMeter.width(), fluidMeterY );
if( VisibleDialog ) {
if( VisibleDialog==&TheAboutTheAuthorDialog || VisibleDialog==&TheLevelContinueDialog )
// Center it on screen
VisibleDialog->drawOn( map, map.width()/2-VisibleDialog->width()/2, map.height()/2-VisibleDialog->height()/2 );
else if( VisibleDialog==&TheKeyboardHelpDialog )
// Put in upper right corner
VisibleDialog->drawOn( map, map.width()*.95f-VisibleDialog->width(), map.height()*.05f );
else
// Put it in upper left portion of seismogram
VisibleDialog->drawOn( map, PanelWidth+24, 24 );
}
int tabTop1 = 50;
int tabTop2 = tabTop1+2*TheFont.height();
int tabLeft1 = PanelWidth/8;
int tabLeft2 = PanelWidth*5/8;
int airGunTop = tabTop2+2*TheFont.height();;
AirgunMeter.drawOn( map, PanelWidth/2-AirgunMeter.width()/2, airGunTop );
if( ShowFrameRate ) {
FrameRateMeter.setValue( EstimateFrameRate() );
FrameRateMeter.drawOn( map, PanelWidth/2-FrameRateMeter.width()/2, fluidMeterY-FrameRateMeter.height()-15 );
}
const int tabSpacing = PanelWidth/4;
DrawClickable( TheFileMenu, map, tabLeft1, tabTop1 );
DrawClickable( TheHelpMenu, map, tabLeft2, tabTop1 );
// The "isTabbed" tests below do some ad-hoc occlusion testing.
if( TheFileMenu.isTabbed() )
DrawClickable( TheModelMenu, map, tabLeft1, tabTop2 );
if( TheFileMenu.isTabbed() && TheHelpMenu.isTabbed() )
//.........这里部分代码省略.........