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


C++ Link::createList方法代码示例

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


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

示例1: main

 int main(int argc, char *argv[])
 {
    string file = "soundFiles.txt";
    Link Files;
    Files.createList(file);

     bool quit=false;
     while(!quit)
     {
         cout<<"===Main Menu==="<<endl;
         cout<<"1. Print Sounds"<<endl;
         cout<<"2. Play Sounds"<<endl;
         cout<<"3. Search"<<endl;
         cout<<"3. Quit"<<endl;
         string answer;
         cin>>answer;

         if(answer=="1")
         {

         }
         else if (answer=="2")
         {
            keySound k;
            k.buildAndPlay();
         }
         else if(answer=="3")
         {

         }

         else if(answer=="4")
         {
             quit=true;
             cout<<"Goodbye!"<<endl;
         }
         else
         {
             cout<<"not a valid input"<<endl;
         }
     }
     return 0;
 }
开发者ID:HelenaKwiat,项目名称:Kwiat_Schneier_Kelley_CSCI2270_FinalProject,代码行数:43,代码来源:main.cpp

示例2: buildAndPlay

//public
void keySound::buildAndPlay(){
  keyS key[8];
  sf::Event event;
  Link Files;
  Files.createList("soundFiles.txt");
  string l = "loops/";

  for(int i=0;i<Files.getSizeVector();i++){//set path to specific file; will change
      l = "loops/";
      if(i==i) key[i].path= l += Files.getFileName(Files.calcASC(i));
      /*if(i==1) key[i].path="loops/kick4.wav";
      if(i==2) key[i].path="loops/kick5.wav";
      if(i==3) key[i].path="loops/kick6.wav";
      if(i==4) key[i].path="loops/kick7.wav";
      if(i==5) key[i].path="loops/kick8.wav";
      if(i==6) key[i].path="loops/kick10.wav";
      if(i==7) key[i].path="loops/kick11.wav";*/
    key[i].buffer.loadFromFile(key[i].path);//load file into buffer
    key[i].loop.setBuffer(key[i].buffer);//load buffer into sound
    key[i].isPlay=false;//set sound to currently not playing
  }

  while(!kb.isKeyPressed(sf::Keyboard::Escape)){
    //if(!sf::Keyboard::Z)break;
    for (size_t i = 0; i < 8; i++) {//cycles through all assigned keys so you can use following code lines simultaneously for all of them
      //if(sf::Keyboard::E)break;
      if (kb.isKeyPressed(keySound::num2Key(i)) && key[i].isPlay==false){//checks if specific key is pressed and correlating sound is already playing
        key[i].isPlay=true;//set the bool to true so the play comand doesn't occur while the loop is playing
        key[i].loop.setPitch(1.0);//normalize sound before playing it
        if (kb.isKeyPressed(kb.LShift)||kb.isKeyPressed(kb.RShift)) {//modify pitch to add flavor when using shift & ctrl
          key[i].loop.setPitch(1.5);//change to higher pitch
          key[i].loop.play();
        } else if (kb.isKeyPressed(kb.LControl)||kb.isKeyPressed(kb.RControl)) {
          key[i].loop.setPitch(0.5);//decrease pitch
          key[i].loop.play();
        } else key[i].loop.play();
      }else if(key[i].loop.getStatus()!=2) key[i].isPlay=false;//set bool back to false so sound can be played again
    }
  }
}
开发者ID:pkel33,项目名称:Kwiat_Schneier_Kelley_CSCI2270_FinalProject,代码行数:41,代码来源:keySound.cpp


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