本文整理汇总了C++中resourcePath函数的典型用法代码示例。如果您正苦于以下问题:C++ resourcePath函数的具体用法?C++ resourcePath怎么用?C++ resourcePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resourcePath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ResourceHolder::ResourceHolder()
{
std::list<sf::String> IDList;
IDList.push_back("Mountains.jpg");
IDList.push_back("Stickmaniac.png");
IDList.push_back("BasicIdle.png");
IDList.push_back("BadAttackAnimation.png");
IDList.push_back("GetHitAnimation.png");
IDList.push_back("RollingWheat.png");
IDList.push_back("cute_image.jpg");
IDList.push_back("icon.png");
sf::Texture dummy;
for (auto ID: IDList) {
textureMap[ID].loadFromFile(resourcePath() + ID);
}
IDList.clear();
IDList.push_back("sansation.ttf");
for (auto && ID: IDList) {
fontMap[ID].loadFromFile(resourcePath() + ID);
}
IDList.clear();
IDList.push_back("nice_music.ogg");
for (auto && ID: IDList) {
musicMap[ID].openFromFile(resourcePath() + ID);
}
}
示例2: text
int TetrisWindow::create()
{
RenderWindow::create(sf::VideoMode(800,600), "Tetris", sf::Style::Close);
// Set the Icon
sf::Image icon;
if (!icon.loadFromFile(resourcePath() + "icon.png")) {
return EXIT_FAILURE;
}
this->setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());
// Create a graphical text to display
sf::Font font;
if (!font.loadFromFile(resourcePath() + "sansation.ttf")) {
return EXIT_FAILURE;
}
sf::Text text("Hello SFML", font, 50);
text.setColor(sf::Color::Black);
// Load a music to play
sf::Music music;
if (!music.openFromFile(resourcePath() + "nice_music.ogg")) {
return EXIT_FAILURE;
}
// Play the music
music.play();
return EXIT_SUCCESS;
};
示例3:
cPlayer::cPlayer(sf::Vector2f pos, bool vertical):
position { pos },
vert { vertical }
{
if ( vertical )
{
shape.setFillColor(sf::Color::White);
shape.setSize(sf::Vector2f(15, 150));
shape.setOrigin(7.5, 75);
tex.loadFromFile(resourcePath()+"paddle_vertical.png");
sprite.setTexture(tex);
sprite.setOrigin(7.5, 75);
}
else
{
shape.setFillColor(sf::Color::White);
shape.setSize(sf::Vector2f(150, 15));
shape.setOrigin(75, 7.5);
tex.loadFromFile(resourcePath()+"paddle_horizontal.png");
sprite.setTexture(tex);
sprite.setOrigin(75, 7.5);
}
invBar.setFillColor(sf::Color::Yellow);
boostBar.setFillColor(sf::Color::Cyan);
saveBar.setFillColor(sf::Color::Green);
score = 10;
}
示例4: View
TrackChooserView::TrackChooserView(const Rect& frame) : View(frame) {
// Get a list of all tracks
Rac0r::TrackFileManager fileManager;
tracks = fileManager.getTrackList();
// Load textures
arrowDownTexture.loadFromFile(resourcePath() + "arrowDown.png");
arrowUpTexture.loadFromFile(resourcePath() + "arrowUp.png");
// Initialize arrows and the track image
arrowRight.setTexture(arrowUpTexture);
arrowRight.rotate(90);
addChild(arrowRight);
arrowLeft.setTexture(arrowDownTexture);
arrowLeft.rotate(90);
addChild(arrowLeft);
addChild(track);
// Select the first track
if (tracks.size() > 0) {
setTrack(0);
}
// Calculate the initial layout. However, it will be recalculated whenever View's setSize() is called.
layoutChildviews();
}
示例5: mWindow
Application::Application()
: mWindow(sf::VideoMode(640, 480), "Menus", sf::Style::Close)
, mTextures()
, mFonts()
, mPlayer()
, mStateStack(State::Context(mWindow, mTextures, mFonts, mPlayer))
, mStatisticsText()
, mStatisticsUpdateTime()
, mStatisticsNumFrames(0)
{
mWindow.setKeyRepeatEnabled(false);
mFonts.load(Fonts::Main, resourcePath() + "Sansation.ttf");
mTextures.load(Textures::TitleScreen, resourcePath() + "TitleScreen.png");
mTextures.load(Textures::ButtonNormal, resourcePath() + "ButtonNormal.png");
mTextures.load(Textures::ButtonSelected, resourcePath() + "ButtonSelected.png");
mTextures.load(Textures::ButtonPressed, resourcePath() + "ButtonPressed.png");
mStatisticsText.setFont(mFonts.get(Fonts::Main));
mStatisticsText.setPosition(5.f, 5.f);
mStatisticsText.setCharacterSize(10u);
registerStates();
mStateStack.pushState(States::Title);
}
示例6: backfile
TileMap::TileMap(std::string const pMapFileName)
{
std::vector<Tile*> tmpMap;
m_mapFileName = pMapFileName;
//initialization of the map with empty tiles
std::ifstream backfile(resourcePath() + "Maps/" + m_mapFileName + "/" + m_mapFileName + "-back.txt");
if (backfile.is_open()) {
std::string tileLocation;
std::getline(backfile, tileLocation);
sf::Image image;
image.loadFromFile(resourcePath() + tileLocation);
image.createMaskFromColor(ALPHA_COLOR);
m_tileTex.loadFromImage(image);
m_tiles.setTexture(m_tileTex);
while (!backfile.eof()) {
std::string line, value;
std::getline(backfile, line);
std::stringstream stream(line);
while (std::getline(stream, value, ',')) {
Tile *tile = new Tile();
tmpMap.push_back(tile);
}
m_map.push_back(tmpMap);
tmpMap.clear();
}
} else
std::cout << "ERROR : Unable to load the tilemap " + m_mapFileName << std::endl;
}
示例7: createUI
// Creates all the buttons.
void RunManager::createUI() {
// Creates the button textures from the file path.
buttonT.loadFromFile(resourcePath() + "Button.png");
button2T.loadFromFile(resourcePath() + "Button2.png");
selectorT.loadFromFile(resourcePath() + "FolderSelector.png");
// Sets the sprites to the texture by using an intermediate sprite.
sf::Sprite encryptButton(button2T);
this->encryptButton = encryptButton;
sf::Sprite decryptButton(button2T);
this->decryptButton = decryptButton;
sf::Sprite ECBButton(buttonT);
this->ECBButton = ECBButton;
sf::Sprite CBCButton(buttonT);
this->CBCButton = CBCButton;
sf::Sprite CTRButton(buttonT);
this->CTRButton = CTRButton;
sf::Sprite encryptFileSelector(selectorT);
this->encryptFileSelector = encryptFileSelector;
sf::Sprite decryptFileSelector(selectorT);
this->decryptFileSelector = decryptFileSelector;
// Sets the respective positions.
this->encryptButton.setPosition(275, 165);
this->decryptButton.setPosition(275, 400);
this->ECBButton.setPosition(37.5, 500);
this->CBCButton.setPosition(337.5, 500);
this->CTRButton.setPosition(637.5, 500);
this->encryptFileSelector.setPosition(150, 65);
this->decryptFileSelector.setPosition(150, 300);
}
示例8: createText
// Largely same as for buttons.
void RunManager::createText() {
// Creates fonts from file path.
buttonFont.loadFromFile(resourcePath() + "typewcond_regular.otf");
titleFont.loadFromFile(resourcePath() + "sansation.ttf");
fileSelectorFont.loadFromFile(resourcePath() + "NixieOne.ttf");
// Sets base text that is used to create other texts by setting size, color and font.
sf::Text blankText;
blankText.setFont(buttonFont);
blankText.setCharacterSize(32);
blankText.setColor(sf::Color::Black);
sf::Text titleText;
titleText.setFont(titleFont);
titleText.setColor(sf::Color::Black);
titleText.setCharacterSize(34);
sf::Text selectorText;
selectorText.setFont(fileSelectorFont);
selectorText.setColor(sf::Color::Black);
selectorText.setCharacterSize(34);
// Sets individual text to base text, sets string and position.
ECBText = blankText;
ECBText.setString("ECB");
ECBText.setPosition(80, 515);
CBCText = blankText;
CBCText.setString("CBC");
CBCText.setPosition(380, 515);
CTRText = blankText;
CTRText.setString("CTR");
CTRText.setPosition(680, 515);
encryptText = blankText;
encryptText.setString("Encrypt");
encryptText.setCharacterSize(52);
encryptText.setPosition(315, 165);
decryptText = blankText;
decryptText.setString("Decrypt");
decryptText.setCharacterSize(52);
decryptText.setPosition(315, 400);
encryptTitleText = titleText;
encryptTitleText.setString("Please select the text file that you wish to encrypt.");
encryptTitleText.setPosition(20, 15);
decryptTitleText = titleText;
decryptTitleText.setString("Please select the text file that you wish to decrypt.");
decryptTitleText.setPosition(20, 250);
encryptFileLocationText = selectorText;
encryptFileLocationText.setPosition(155, 77.5);
decryptFileLocationText = selectorText;
decryptFileLocationText.setPosition(155, 312.5);
}
示例9: resourcePath
void World::loadTextures()
{
mTextures.load(Textures::Entities, resourcePath() + TEXTURES + "Entities.png");
mTextures.load(Textures::Jungle, resourcePath() + TEXTURES + "Jungle.png");
mTextures.load(Textures::Explosions, resourcePath() + TEXTURES + "Explosion.png");
mTextures.load(Textures::Particle, resourcePath() + TEXTURES + "Particle.png");
mTextures.load(Textures::FinishLine, resourcePath() + TEXTURES + "FinishLine.png");
}
示例10: resourcePath
QString AsemanDevices::resourcePathQml()
{
#ifdef Q_OS_ANDROID
return resourcePath();
#else
return localFilesPrePath() + resourcePath();
#endif
}
示例11: main
int main(int, char const**) {
// Window
sf::RenderWindow window(sf::VideoMode(800, 600), "Motor City");
// Icon
sf::Image icon;
if (!icon.loadFromFile(resourcePath() + "icon.png")) {
return EXIT_FAILURE;
}
window.setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());
// Background
sf::Texture texture;
if (!texture.loadFromFile(resourcePath() + "Background.jpg")) {
return EXIT_FAILURE;
}
sf::Sprite background(texture);
// Creating world
World world;
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed) {
window.close();
}
// Escape pressed : exit
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
window.close();
}
}
// Clear window
window.clear();
// Update simulation
world.update();
// Draw background
window.draw(background);
// Draw simulation
window.draw(world);
// Update the window
window.display();
}
return EXIT_SUCCESS;
}
示例12: Sprite
Player::Player(sf::Texture &img, int w, int h, int speed) : Sprite(img, sf::Vector2i(0,0), SOUTH, w, h, speed) {
life = 4;
no.loadFromFile(resourcePath() + "no.wav");
hit.loadFromFile(resourcePath() + "hit.wav");
kiss.loadFromFile(resourcePath() + "kiss.wav");
heart.loadFromFile(resourcePath() + "heart.png");
CreateAnimations(3);
}
示例13: configManager
MainGame::MainGame()
{
ConfigurationManager configManager(resourcePath() + "configuration.txt");
//if SDL fails, close program
if (SDL_Init(SDL_INIT_VIDEO)) throw std::logic_error("Failed to initialize SDL! " + std::string(SDL_GetError()));
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
if (configManager.GetItem<bool>("Multisampling"))
{
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, configManager.GetItem<int>("MultisampleBuffers"));
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, configManager.GetItem<int>("MultisampleSamples"));
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_DisplayMode mode; SDL_GetCurrentDisplayMode(0, &mode);
Uint32 windowFlags = SDL_WINDOW_OPENGL;
size_t width = configManager.GetItem<float>("WindowWidth"), height = configManager.GetItem<float>("WindowHeight");
if (configManager.GetItem<bool>("Fullscreen"))
{
// width = mode.w; height = mode.h;
windowFlags|=SDL_WINDOW_FULLSCREEN_DESKTOP;
}
window = SDL_CreateWindow("Genetic Algorithm", 0, 0, width, height, windowFlags);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetSwapInterval(1);
SDL_SetRelativeMouseMode(SDL_TRUE);
if (window==nullptr) throw std::logic_error("Window failed to be initialized");
SDL_GLContext context = SDL_GL_CreateContext(window);
if (context==nullptr) throw std::logic_error("SDL_GL could not be initialized!");
int cpuCount = SDL_GetCPUCount();
GLManager glManager(resourcePath() + "fragmentShader.glsl", resourcePath() + "vertexShader.glsl", configManager);
std::string fileLoc =resourcePath() + "performance.csv";
EvolutionSystem evolutionSystem(fileLoc, configManager, cpuCount);
Camera camera(configManager.GetItem<float>("WindowWidth"), configManager.GetItem<float>("WindowHeight"), configManager);
while (GameState!=GameState::EXIT)
{
Update(evolutionSystem);
camera.Update();
glManager.Programs[0].SetMatrix4("transformMatrix", glm::value_ptr(camera.GetTransformMatrix()));
Draw(evolutionSystem);
SDL_GL_SwapWindow(window);
HandleEvents(evolutionSystem,camera);
}
}
示例14: wxFrame
StagePreview::StagePreview(MenuBarMaker *menuBarMaker)
: wxFrame(NULL, wxID_ANY, "Preview", wxDefaultPosition, wxDefaultSize,
wxDEFAULT_FRAME_STYLE & ~ (wxRESIZE_BORDER | wxMAXIMIZE_BOX)) {
menuBarMaker_ = menuBarMaker;
menusInitialized_ = false;
fileManager_ = new FileManager();
listener_ = 0;
previewGfxManager_ = new GfxManager(resourcePath(), false);
stageName_ = 0;
#ifdef __WINDOWS__
SetIcon(wxIcon(resourcePath() + BERRYBOTS_ICO, wxBITMAP_TYPE_ICO));
// The 8-9 point default font size in Windows is much smaller than Mac/Linux.
wxFont windowFont = GetFont();
if (windowFont.GetPointSize() <= 9) {
SetFont(windowFont.Larger());
}
#elif __WXGTK__
SetIcon(wxIcon(resourcePath() + BBICON_128, wxBITMAP_TYPE_PNG));
#endif
mainPanel_ = new wxPanel(this);
infoSizer_ = new wxStaticBoxSizer(wxVERTICAL, mainPanel_);
descSizer_ = new wxStaticBoxSizer(wxVERTICAL, mainPanel_);
wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
mainSizer->Add(mainPanel_, 0, wxEXPAND);
wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
wxImage iconImg;
iconImg.LoadFile(std::string(resourcePath() + BBICON_128).c_str());
visualPreview_ = new wxStaticBitmap(mainPanel_, wxID_ANY, wxBitmap(iconImg));
topSizer->Add(visualPreview_, 0, wxALIGN_CENTER);
topSizer->AddSpacer(8);
wxBoxSizer *rowSizer = new wxBoxSizer(wxHORIZONTAL);
rowSizer->Add(infoSizer_, 0, wxEXPAND);
rowSizer->AddSpacer(4);
rowSizer->Add(descSizer_, 1, wxEXPAND);
topSizer->Add(rowSizer, 0, wxEXPAND);
wxBoxSizer *borderSizer = new wxBoxSizer(wxVERTICAL);
borderSizer->Add(topSizer, 0, wxALL | wxEXPAND, 12);
mainPanel_->SetSizerAndFit(borderSizer);
SetSizerAndFit(mainSizer);
Connect(this->GetId(), wxEVT_ACTIVATE,
wxActivateEventHandler(StagePreview::onActivate));
Connect(this->GetId(), wxEVT_CLOSE_WINDOW,
wxCommandEventHandler(StagePreview::onClose));
eventFilter_ = new PreviewEventFilter(this);
this->GetEventHandler()->AddFilter(eventFilter_);
}
示例15: init_font
void game :: init_font(){
// char cwd[1024];
// if (getcwd(cwd, sizeof(cwd)) != NULL) fprintf(stdout, "Current working dir: %s\n", cwd);
// else perror("getcwd() error");
// profont is 9, 04b is 8
string fontfilename =
"ProFontWindows.ttf"
//"Minecraftia.ttf"
,
fontfilename2 =
"04B_03.TTF" // comment either
//"ProFontWindows.ttf" // comment either
;
// "slkscr.ttf"
chsz=9;
chsz2=8;
fontfilename = cfg->getstring("font1");
fontfilename2 = cfg->getstring("font2");
chsz=cfg->getint("fontsize1");
chsz2=cfg->getint("fontsize2");
int overridefont = conf.getint("overridefont");
switch(overridefont)
{
case 1: fontfilename2=fontfilename; chsz2=chsz; break;
case 2: fontfilename=fontfilename2; chsz=chsz2; break;
default:break;
}
if(!ft.loadFromFile(
#ifdef __APPLE__
resourcePath()+
#endif
fontfilename.c_str()))
cout << "could not open " << fontfilename << endl;
else cout << "successfully loaded " << fontfilename <<endl;
//if(!ff2.loadFromFile(
if(!ft2.loadFromFile(
#ifdef __APPLE__
resourcePath()+
#endif
fontfilename2.c_str()))
cout << "could not open " << fontfilename2 << endl;
else cout << "successfully loaded " << fontfilename2 <<endl;
((sf::Texture&)ft .getTexture(chsz)).setSmooth(false);
((sf::Texture&)ft2 .getTexture(chsz2)).setSmooth(false);
}