本文整理汇总了C++中SpriteSheet::getAllFrames方法的典型用法代码示例。如果您正苦于以下问题:C++ SpriteSheet::getAllFrames方法的具体用法?C++ SpriteSheet::getAllFrames怎么用?C++ SpriteSheet::getAllFrames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpriteSheet
的用法示例。
在下文中一共展示了SpriteSheet::getAllFrames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: idleSheet
Player::Player(PlatformState& platformState, BoxWorld* world, sf::Vector2f& size, sf::Vector2f& position, ResourceCollection& resource, LightSolver* lightSolver, StatManager& stats)
: Entity(world, size, position)
, mPlatformState(platformState)
, groundCallBack(nullptr)
, leftButton(false)
, rightButton(false)
, downButton(false)
, mResource(resource)
, flashLight(lightSolver->createLight(FLASHLIGHT_SIZE.x, FLASHLIGHT_SIZE.y))
, maskRight(&resource.getTexture("Assets/Shader/mask.png"))
, maskLeft(flipTexture(maskRight))
, activeStreetLight(nullptr)
, collisionFixture(body->GetFixtureList())
, mStats(stats)
, flashLightBody(world->createEntityBody(sf::Vector2f(0.0f, 0.0f), static_cast<sf::Vector2f>(FLASHLIGHT_SIZE), false))
{
flashLight->setColor(sf::Color(255, 255, 0, 150));
int group = flashLight->getFilterGroup();
group |= (1 << 8);
flashLight->setFilterGroup(group);
setFilterGroup(getFilterGroup() | (1 << 8));
setState(PLAYER_STATE::NORMAL);
/* Walking/run animation */
auto &walking = mResource.getTexture("Assets/Characters/Stella Left.png");
sf::Vector2i walkingSize = static_cast<sf::Vector2i>(walking.getSize());
sf::Vector2i frameSize(256, 256);
SpriteSheet spritesheet1(frameSize, walkingSize);
std::vector<sf::IntRect> frames = spritesheet1.getAllFrames();
mWalking = new Animation(frames,walking);
/* Idle animation */
auto &idle = mResource.getTexture("Assets/Characters/Stella idle.png");
sf::Vector2i idleSize = static_cast<sf::Vector2i>(idle.getSize());
SpriteSheet idleSheet(frameSize,idleSize);
std::vector<sf::IntRect> idleFrames = idleSheet.getAllFrames();
mIdle = new Animation(idleFrames,idle);
/* Jump animation */
auto &jump = mResource.getTexture("Assets/Characters/Stella jump.png");
sf::Vector2i jumpSize = static_cast<sf::Vector2i>(jump.getSize());
SpriteSheet jumpSheet(frameSize,jumpSize);
std::vector<sf::IntRect> jumpFrames = jumpSheet.getAllFrames();
mJump = new Animation(jumpFrames,jump);
/* Grab animation */
auto &grab = mResource.getTexture("Assets/Characters/Stella grab.png");
sf::Vector2i grabSize = static_cast<sf::Vector2i>(grab.getSize());
SpriteSheet grabSheet (frameSize, grabSize);
std::vector<sf::IntRect> grabFrames = grabSheet.getAllFrames();
mGrab = new Animation(grabFrames,grab);
/* Fall Animation*/
auto &fall = mResource.getTexture("Assets/Characters/Stella fall.png");
sf::Vector2i fallSize = static_cast<sf::Vector2i>(fall.getSize());
SpriteSheet fallSheet(frameSize, fallSize);
std::vector<sf::IntRect> fallFrames = jumpSheet.getAllFrames();
mFall = new Animation(fallFrames,fall);
/* Hit Animation*/
auto &hit = mResource.getTexture("Assets/Characters/Stella hit.png");
sf::Vector2i hitSize = static_cast<sf::Vector2i>(hit.getSize());
SpriteSheet hitSheet(frameSize, hitSize);
std::vector<sf::IntRect> hitFrames = hitSheet.getAllFrames();
mHit = new Animation(hitFrames,hit);
anime.setAnimation(*mIdle);
updateSpriteOrigin();
mJumpSound = new sf::Sound;
mJumpSound->setBuffer(*mResource.getSound("Assets/Sound/Jump.wav"));
mWalkSound = new sf::Sound;
mWalkSound->setBuffer(*mResource.getSound("Assets/Sound/Stella_Run_Loop_1.wav"));
mWalkSound->setVolume(40);
mHurtSound = new sf::Sound;
mHurtSound->setBuffer(*mResource.getSound("Assets/Sound/Stella get hurt.wav"));
setupSensors(position, size);
body->SetLinearDamping(1.0f);
/* Set filter for collisions */
b2Filter filter = collisionFixture->GetFilterData();
filter.categoryBits = PLAYER;
//filter.maskBits =ALL, ENEMY_CHASE, ENEMY_ATTACK;
filter.groupIndex = ALL, ENEMY_CHASE, ENEMY_ATTACK;
collisionFixture->SetFilterData(filter);
knockForce = 35;
toggle = false;
}