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


C++ Fish类代码示例

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


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

示例1: isFishConfigured

void FishCollection::addFishAtHwId(unsigned int fishHwId)
{
  bool found = isFishConfigured(fishHwId);

  if (!found)
  {
    Fish* fish = new Fish(fishHwId, this);
    if (0 == m_fish)
    {
      m_fish = fish;
    }
    else
    {
      Fish* next = m_fish;
      while (next->next() != 0)
      {
        next = next->next();
      }
      next->setNext(fish);
    }
    if (0 != m_adapter)
    {
      // Notify: Fish with the particular HW ID created!
      m_adapter->notifyFishEvent(fishHwId, FishNotificationAdapter::EvtFishAdded);
    }
  }
  else
  {
    if (0 != m_adapter)
    {
      // ERROR: Fish with the particular HW ID already exists, no new fish created!
      m_adapter->notifyFishError(fishHwId, FishNotificationAdapter::ErrFishAlreadyExists);
    }
  }
}
开发者ID:ERNICommunity,项目名称:iof-aquarium-controller,代码行数:35,代码来源:FishCollection.cpp

示例2: main

int main(int argc, char ** argv) {
    Fish f;
    f.numBones();
    f.spooky();

    return 0;
}
开发者ID:jgillis,项目名称:Eg,代码行数:7,代码来源:helloworld.cpp

示例3: Fish

Fish* Fish::create(FishType type)
{
    Fish* fish = new Fish();
    fish->init(type);
    fish->autorelease();
    return fish;
}
开发者ID:TanCYA,项目名称:FishingJoy,代码行数:7,代码来源:Fish.cpp

示例4: TrackFish

bool Fish::TrackFish(Fish fish)
{
	if(!fish.IsDanglingFish()) return false;
	if(IsTheFish(fish))
	{
		UpdateBoundingRect(fish.GetBoundingRect());
		return true;
	}
}
开发者ID:Momo-FW,项目名称:WorkStation,代码行数:9,代码来源:Fish.cpp

示例5: Fish

Fish* Fish::create() {
    Fish *sprite = new Fish();
    if (sprite && sprite->initWithFile("turtle_1.png")){
        sprite->setup();
        sprite->autorelease();
        return sprite;
    }
    CC_SAFE_DELETE(sprite);
    return nullptr;
}
开发者ID:areschoug,项目名称:LD29,代码行数:10,代码来源:Fish.cpp

示例6: main

int main()
{
    Fish* fish = Fish_new();    // 创建鱼对象
    Dog* dog = Dog_new();       // 创建狗对象
    Car* car = Car_new();       // 创建车子对象

    Animal* animals[2] = { 0 };     // 初始化动物容器(这里是Animal指针数组)
    IMoveable* moveObjs[3] = { 0 }; // 初始化可移动物体容器(这里是IMoveable指针数组)

    int i = 0;                  // i和j是循环变量
    int j = 0;

    // 初始化鱼对象的昵称为:小鲤鱼,年龄为:1岁
    fish->init(fish, "Small carp", 1);

    // 将fish指针转型为Animal类型指针,并赋值给animals数组的第一个成员
    animals[0] = SUPER_PTR(fish, Animal);

    // 初始化狗对象的昵称为:牧羊犬,年龄为:2岁
    dog->init(dog, "sheepdog", 2);

    // 将dog指针转型为Animal类型指针,并赋值给animals数组的第二个成员
    animals[1] = SUPER_PTR(dog, Animal);

    // 将fish指针转型为IMoveable接口类型指针,并赋值给moveOjbs数组的第一个成员
    moveObjs[0] = SUPER_PTR(fish, IMoveable);

    // 将dog指针转型为IMoveable接口类型指针,并赋值给moveOjbs数组的第二个成员
    moveObjs[1] = SUPER_PTR(dog, IMoveable);

    // 将car指针转型为IMoveable接口类型指针,并赋值给moveOjbs数组的第三个成员
    moveObjs[2] = SUPER_PTR(car, IMoveable);

    // 循环打印动物容器内的动物信息
    for(i=0; i<2; i++)
    {
        Animal* animal = animals[i];
        animal->eat(animal);
        animal->breathe(animal);
        animal->sayHello(animal);
    }

    // 循环打印可移动物体容器内的可移动物体移动方式的信息
    for(j=0; j<3; j++)
    {
        IMoveable* moveObj = moveObjs[j];
        moveObj->move(moveObj);
    }

    lw_oopc_delete(fish);
    lw_oopc_delete(dog);
    lw_oopc_delete(car);

    return 0;
}
开发者ID:andycodes,项目名称:helloworld,代码行数:55,代码来源:main.c

示例7:

HarvestSpriteProduceStrategy::AddFish(float delta)
{
	timeSinceLastAddFish += delta;
	if(timeSinceLastAddFish > ADD_FISH_TIME_INTERVAL) {
		timeSinceLastAddFish = 0.0f;
		if(rand() % 5 == 0) {
			Fish *fish = SpriteFactory::GetInstance()->CreateFish(component->model);
			fish->SetComponent(component);
			component->fishes->Add(fish);
		}
	}
}
开发者ID:jigangftp8,项目名称:OceanPlanet,代码行数:12,代码来源:HarvestSpriteProduceStrategy.cpp

示例8: main

int main(){
    cout << sizeof(Animal) << endl;
    cout << sizeof(Cat)  << endl;
	Cat  cat;
	cat.show();
	cat.catfun();
	Fish  fish;
    fish.name="test";
	fish.age=10;
    fish.type="a";
	fish.show();
	fish.fishfun();
}
开发者ID:isongbo,项目名称:MyCode,代码行数:13,代码来源:07inheritance.cpp

示例9: main

int main()
{
	Fish myFish;
	Bear myBear;
	Dinosaur myDino;

	cout << "Fish eats bear? " << myFish.eats(myBear) << endl;
	cout << "Fish eats dino? " << myFish.eats(myDino) << endl;
	cout << "Dino eats bear? " << myDino.eats(myBear) << endl;
	cout << "Bear eats fish? " << myBear.eats(myFish) << endl;

	return 0;
}
开发者ID:EmuxEvans,项目名称:Woody-Ye-s-Code-Share,代码行数:13,代码来源:DoubleDispatch.cpp

示例10: Whitefish

void Aquarium::init(void) {
	if(_doLog) cout << "init" << endl;
	for(int i=0; i<_start_n_whitefish; i++) {
		Fish *fish = new Whitefish();
		fish->set_baby(false);
		if(!addFish(fish)) delete fish;
	}

	for(int i=0; i<_start_n_predator; i++) {
		Fish *fish = new Predator(i+_start_n_whitefish);
		if(!addFish(fish)) delete fish;
	}
}
开发者ID:avitase,项目名称:uninf,代码行数:13,代码来源:Aquarium.cpp

示例11: Fish

Fish *Fish::createWithFishType(int fishType, GameLayer *gameLayer, CCSpriteBatchNode *pBatchNode)
{
    Fish *fish = new Fish();
    if(fish && fish->initWithFishType(fishType, gameLayer, pBatchNode))
    {
        fish->autorelease();
        return fish;
    }
    else
    {
        delete fish;
        return NULL;
    }
}
开发者ID:37-int,项目名称:fishingjoy,代码行数:14,代码来源:Fish.cpp

示例12: glClear

void Scene::display() {
	// Clear screen, initialise culling
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Select model view matrix
	glMatrixMode(GL_MODELVIEW);

	// Draw solid bodies
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	glLoadIdentity();

	Fish* f = Fish::getFirst();
	Vector* v = f->getPosition();
	GLfloat lightPos[] = { static_cast<GLfloat>(v->x),
		static_cast<GLfloat>(v->y - 10), static_cast<GLfloat>(v->z), 1.0 };
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

	// args 1-3: viewer coordinates,
	// args 4-5: point looked at,
	// args 7-9: "up" vector
	gluLookAt(
		camPos[activeCam]->x, camPos[activeCam]->y, camPos[activeCam]->z,
		0.0, 20.0, 0.0,
		0.0, 1.0, 0.0);

	// Draw scene graph
	fishList->work();
	if (!calculateFishCount) {
		sharkList->work();
	}
	graph->work();

	if (drawNames) {
		Text::drawAll();
	} else {
		fpsDisplay->draw();
		for (list<Text*>::iterator it = helpDisplay.begin(); it != helpDisplay.end(); it++) {
			(*it)->draw();
		}
	}

	glFlush();
	glutSwapBuffers();

	if (calculateFishCount) {
		glutPostRedisplay();
	}
	frames++;
}
开发者ID:atextor,项目名称:fishtank,代码行数:50,代码来源:Scene.cpp

示例13: create

Fish* Fish::create(FishType type/* = k_Fish_Type_SmallFish */)
{
	Fish* fish = new Fish;
	if (fish && fish->init(type))
	{
		fish->autorelease();
		return fish;
	}
	else
	{
		CC_SAFE_DELETE(fish);
		return NULL;
	}
}
开发者ID:hefeng1996,项目名称:FishingJoy,代码行数:14,代码来源:Fish.cpp

示例14: CCRANDOM_0_1

void FishLayer::addFish(float dt){
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	//随机增加Fish
	int countToAdd = CCRANDOM_0_1() * 20 + 1;
	int countHasAdded = 0;
	CCObject* iterator;
	CCARRAY_FOREACH(_fishes, iterator){
		Fish* fish = (Fish*)iterator;
		if (fish->getParent() == NULL){
			this->addChild(fish);
			this->resetFish(fish);
			countHasAdded++;
			if (countHasAdded == countToAdd){
				break;
			}
		}
	}
开发者ID:JimiWasBornIn1988,项目名称:FishingJoy,代码行数:17,代码来源:FishLayer.cpp

示例15: timeExpired

 void timeExpired()
 {
   if (!m_fishCollection->queue()->isEmpty() && !m_fishCollection->isBusy())
   {
     Fish* fish = m_fishCollection->queue()->dequeue();
     if (0 != fish)
     {
       fish->activateMotion();
     }
     else
     {
       if (0 != m_fishCollection->adapter())
       {
         m_fishCollection->adapter()->notifyFishError(0, FishNotificationAdapter::ErrFishQueueCorrupt);
       }
     }
   }
 }
开发者ID:ERNICommunity,项目名称:iof-aquarium-controller,代码行数:18,代码来源:FishCollection.cpp


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