本文整理汇总了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);
}
}
}
示例2: main
int main(int argc, char ** argv) {
Fish f;
f.numBones();
f.spooky();
return 0;
}
示例3: Fish
Fish* Fish::create(FishType type)
{
Fish* fish = new Fish();
fish->init(type);
fish->autorelease();
return fish;
}
示例4: TrackFish
bool Fish::TrackFish(Fish fish)
{
if(!fish.IsDanglingFish()) return false;
if(IsTheFish(fish))
{
UpdateBoundingRect(fish.GetBoundingRect());
return true;
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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();
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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++;
}
示例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;
}
}
示例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;
}
}
}
示例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);
}
}
}
}