当前位置: 首页>>代码示例>>C++>>正文


C++ Animation::AddFrame方法代码示例

本文整理汇总了C++中Animation::AddFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ Animation::AddFrame方法的具体用法?C++ Animation::AddFrame怎么用?C++ Animation::AddFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Animation的用法示例。


在下文中一共展示了Animation::AddFrame方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateAnimations

void Player::CreateAnimations(int rows) {
    sf::IntRect image = {0, 128, width, height};
    
    // Create animation ATTACK_SOUTH
    Animation *south = new Animation;
    image.left = 0;
    
    for (int i = 0; i < rows; i++) {
        south->AddFrame(image, 150);
        image.left += width;
    }
    
    AddAnimation(ATTACK_SOUTH, south);
    
    image.top += height;
    
    // Create animation ATTACK_WEST
    Animation *west = new Animation;
    image.left = 0;
    
    for (int i = 0; i < rows; i++) {
        west->AddFrame(image, 150);
        image.left += width;
    }
    
    AddAnimation(ATTACK_WEST, west);
    
    image.top += height;
    
    // Create animation ATTACK_EAST
    Animation *east = new Animation;
    image.left = 0;
    
    for (int i = 0; i < rows; i++) {
        east->AddFrame(image, 150);
        image.left += width;
    }
    
    AddAnimation(ATTACK_EAST, east);
    
    image.top += height;
    
    // Create animation ATTACK_NORTH
    Animation *north = new Animation;
    image.left = 0;
    
    for (int i = 0; i < rows; i++) {
        north->AddFrame(image, 150);
        image.left += width;
    }
    
    AddAnimation(ATTACK_NORTH, north);
}
开发者ID:danielbreves,项目名称:HeroMustSavePrincess,代码行数:53,代码来源:Player.cpp

示例2: Animation

Player::Player(PlatformerScene* scenePtr, const float32 x = 0, const float32 y = 0) {
	currentState = PlayerState::JUMPING;
	animations = new std::vector<Animation*>();
	scenePtr->CreateCircleGameObject(this, "res/placeholders/player/idle/idle0.png", x, y, b2_dynamicBody, 25, 0.5);
	
	body->SetFixedRotation(true);
	// There is no spritesheet class, so we are adding individual images to the animation

	//TODO: ->SetBlendMode(SDL_BLENDMODE_BLEND) .. enable alpha transparency on the images
	// NTS: The images dont have transparency yet, I tested it and it works

	Animation* anim = new Animation(0.08f);
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/idle/idle0.png", SDL_BLENDMODE_BLEND));
	animations->push_back(anim);

	anim = new Animation(0.08f);
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/run/pl1.png", SDL_BLENDMODE_BLEND));
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/run/pl2.png", SDL_BLENDMODE_BLEND));
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/run/pl3.png", SDL_BLENDMODE_BLEND));
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/run/pl4.png", SDL_BLENDMODE_BLEND));
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/run/pl5.png", SDL_BLENDMODE_BLEND));
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/run/pl6.png", SDL_BLENDMODE_BLEND));
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/run/pl7.png", SDL_BLENDMODE_BLEND));
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/run/pl8.png", SDL_BLENDMODE_BLEND));
	animations->push_back(anim);

	// then we add the animation to a collection of animations
	anim = new Animation(0.08f, false);
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/jump/jump0.png", SDL_BLENDMODE_BLEND));
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/jump/jump1.png", SDL_BLENDMODE_BLEND));
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/jump/jump2.png", SDL_BLENDMODE_BLEND));
	anim->AddFrame(scenePtr->LoadTexture("res/placeholders/player/jump/jump3.png", SDL_BLENDMODE_BLEND));
	animations->push_back(anim);
}
开发者ID:cathoangludi,项目名称:Watermelon,代码行数:34,代码来源:Player.cpp

示例3: GenerateWeatherAnimations

void World::GenerateWeatherAnimations()
{
	Animation* anim;
	int animframe;

	anim = new Animation( visualSprites, true, SPRITE_WORLD_SPEED );
	for( animframe = 0; animframe < mapData->GetArraySize( "Overworld.Animations.Weather.Sunny" ); animframe++ )
	{
		anim->AddFrame( mapData->GetQuickIntegerValue( "Overworld.Animations.Weather.Sunny", animframe, 0 ) );
	}
	WeatherAnimations.push_back( anim );

	anim = new Animation( visualSprites, true, SPRITE_WORLD_SPEED );
	for( animframe = 0; animframe < mapData->GetArraySize( "Overworld.Animations.Weather.Warning" ); animframe++ )
	{
		anim->AddFrame( mapData->GetQuickIntegerValue( "Overworld.Animations.Weather.Warning", animframe, 0 ) );
	}
	WeatherAnimations.push_back( anim );

	anim = new Animation( visualSprites, true, SPRITE_WORLD_SPEED );
	for( animframe = 0; animframe < mapData->GetArraySize( "Overworld.Animations.Weather.LightSnow" ); animframe++ )
	{
		anim->AddFrame( mapData->GetQuickIntegerValue( "Overworld.Animations.Weather.LightSnow", animframe, 0 ) );
	}
	WeatherAnimations.push_back( anim );

	anim = new Animation( visualSprites, true, SPRITE_WORLD_SPEED );
	for( animframe = 0; animframe < mapData->GetArraySize( "Overworld.Animations.Weather.HeavySnow" ); animframe++ )
	{
		anim->AddFrame( mapData->GetQuickIntegerValue( "Overworld.Animations.Weather.HeavySnow", animframe, 0 ) );
	}
	WeatherAnimations.push_back( anim );

	anim = new Animation( visualSprites, true, SPRITE_WORLD_SPEED );
	for( animframe = 0; animframe < mapData->GetArraySize( "Overworld.Animations.Weather.DeathSnow" ); animframe++ )
	{
		anim->AddFrame( mapData->GetQuickIntegerValue( "Overworld.Animations.Weather.DeathSnow", animframe, 0 ) );
	}
	WeatherAnimations.push_back( anim );
}
开发者ID:pmprog,项目名称:deathsnow,代码行数:40,代码来源:world.cpp

示例4: LoadCursors

void MouseHelper::LoadCursors()
{
    Image *pCursorSpriteSheet = ResourceLoader::GetInstance()->LoadImage("image/CursorSpriteSheet.png");

    //// NORMAL CURSOR ////

    CommonCaseResources::GetInstance()->GetSpriteManager()->AddImage(cursorSpriteSheetId, pCursorSpriteSheet);

    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(normalCursorSpriteId01, cursorSpriteSheetId, RectangleWH(0,   0, 30, 30));

    Animation *pNormalCursorAnimation = NULL;
    CommonCaseResources::GetInstance()->GetAnimationManager()->AddAnimation(normalCursorAnimationId, &pNormalCursorAnimation);
    pNormalCursorAnimation->AddFrame(5000, normalCursorSpriteId01);

    animationByCursorTypeMap[CursorTypeNormal] = pNormalCursorAnimation;

    //// LOOK CURSOR ////

    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(lookCursorSpriteId01, cursorSpriteSheetId, RectangleWH(0,   30, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(lookCursorSpriteId02, cursorSpriteSheetId, RectangleWH(30,  30, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(lookCursorSpriteId03, cursorSpriteSheetId, RectangleWH(60,  30, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(lookCursorSpriteId04, cursorSpriteSheetId, RectangleWH(90,  30, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(lookCursorSpriteId05, cursorSpriteSheetId, RectangleWH(120, 30, 30, 30));

    Animation *pLookCursorAnimation = NULL;
    CommonCaseResources::GetInstance()->GetAnimationManager()->AddAnimation(lookCursorAnimationId, &pLookCursorAnimation);
    pLookCursorAnimation->AddFrame(1932, lookCursorSpriteId01);
    pLookCursorAnimation->AddFrame(84, lookCursorSpriteId02);
    pLookCursorAnimation->AddFrame(84, lookCursorSpriteId03);
    pLookCursorAnimation->AddFrame(84, lookCursorSpriteId04);
    pLookCursorAnimation->AddFrame(84, lookCursorSpriteId05);

    animationByCursorTypeMap[CursorTypeLook] = pLookCursorAnimation;

    //// TALK CURSOR ////

    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(talkCursorSpriteId01, cursorSpriteSheetId, RectangleWH(0,   60, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(talkCursorSpriteId02, cursorSpriteSheetId, RectangleWH(30,  60, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(talkCursorSpriteId03, cursorSpriteSheetId, RectangleWH(60,  60, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(talkCursorSpriteId04, cursorSpriteSheetId, RectangleWH(90,  60, 30, 30));

    Animation *pTalkCursorAnimation = NULL;
    CommonCaseResources::GetInstance()->GetAnimationManager()->AddAnimation(talkCursorAnimationId, &pTalkCursorAnimation);
    pTalkCursorAnimation->AddFrame(210, talkCursorSpriteId01);
    pTalkCursorAnimation->AddFrame(210, talkCursorSpriteId02);
    pTalkCursorAnimation->AddFrame(210, talkCursorSpriteId03);
    pTalkCursorAnimation->AddFrame(500, talkCursorSpriteId04);

    animationByCursorTypeMap[CursorTypeTalk] = pTalkCursorAnimation;

    //// EXIT NORTH CURSOR ////

    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthCursorSpriteId01, cursorSpriteSheetId, RectangleWH(0,   90, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthCursorSpriteId02, cursorSpriteSheetId, RectangleWH(30,  90, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthCursorSpriteId03, cursorSpriteSheetId, RectangleWH(60,  90, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthCursorSpriteId04, cursorSpriteSheetId, RectangleWH(90,  90, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthCursorSpriteId05, cursorSpriteSheetId, RectangleWH(120, 90, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthCursorSpriteId06, cursorSpriteSheetId, RectangleWH(150, 90, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthCursorSpriteId07, cursorSpriteSheetId, RectangleWH(180, 90, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthCursorSpriteId08, cursorSpriteSheetId, RectangleWH(210, 90, 30, 30));

    Animation *pExitNorthCursorAnimation = NULL;
    CommonCaseResources::GetInstance()->GetAnimationManager()->AddAnimation(exitNorthCursorAnimationId, &pExitNorthCursorAnimation);
    pExitNorthCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthCursorSpriteId01);
    pExitNorthCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthCursorSpriteId02);
    pExitNorthCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthCursorSpriteId03);
    pExitNorthCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthCursorSpriteId04);
    pExitNorthCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthCursorSpriteId05);
    pExitNorthCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthCursorSpriteId06);
    pExitNorthCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthCursorSpriteId07);
    pExitNorthCursorAnimation->AddFrame(exitAnimationHoldFrameDurationMs, exitNorthCursorSpriteId08);

    animationByCursorTypeMap[CursorTypeExitNorth] = pExitNorthCursorAnimation;

    //// EXIT NORTHEAST CURSOR ////

    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthEastCursorSpriteId01, cursorSpriteSheetId, RectangleWH(0,   120, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthEastCursorSpriteId02, cursorSpriteSheetId, RectangleWH(30,  120, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthEastCursorSpriteId03, cursorSpriteSheetId, RectangleWH(60,  120, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthEastCursorSpriteId04, cursorSpriteSheetId, RectangleWH(90,  120, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthEastCursorSpriteId05, cursorSpriteSheetId, RectangleWH(120, 120, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthEastCursorSpriteId06, cursorSpriteSheetId, RectangleWH(150, 120, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthEastCursorSpriteId07, cursorSpriteSheetId, RectangleWH(180, 120, 30, 30));
    CommonCaseResources::GetInstance()->GetSpriteManager()->AddSprite(exitNorthEastCursorSpriteId08, cursorSpriteSheetId, RectangleWH(210, 120, 30, 30));

    Animation *pExitNorthEastCursorAnimation = NULL;
    CommonCaseResources::GetInstance()->GetAnimationManager()->AddAnimation(exitNorthEastCursorAnimationId, &pExitNorthEastCursorAnimation);
    pExitNorthEastCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthEastCursorSpriteId01);
    pExitNorthEastCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthEastCursorSpriteId02);
    pExitNorthEastCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthEastCursorSpriteId03);
    pExitNorthEastCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthEastCursorSpriteId04);
    pExitNorthEastCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthEastCursorSpriteId05);
    pExitNorthEastCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthEastCursorSpriteId06);
    pExitNorthEastCursorAnimation->AddFrame(exitAnimationNormalFrameDurationMs, exitNorthEastCursorSpriteId07);
    pExitNorthEastCursorAnimation->AddFrame(exitAnimationHoldFrameDurationMs, exitNorthEastCursorSpriteId08);

    animationByCursorTypeMap[CursorTypeExitNorthEast] = pExitNorthEastCursorAnimation;

    //// EXIT EAST CURSOR ////

//.........这里部分代码省略.........
开发者ID:Abion47,项目名称:my-little-investigations,代码行数:101,代码来源:MouseHelper.cpp


注:本文中的Animation::AddFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。