Esempio n. 1
0
    static void activateCallback(CoreAPI *This, Header *header, UserData userData)
    {
        This->activateCallback(This, header);

        MyObject* m = (MyObject*)userData;
        volatile unsigned short ack_data;
        if (header->length - EXC_DATA_SIZE <= 2)
        {
            memcpy((unsigned char *)&ack_data, ((unsigned char *)header) + sizeof(Header),
                   (header->length - EXC_DATA_SIZE));
            if (ack_data == ACK_ACTIVE_NEW_DEVICE)
            {
                printf("New Device");
            }
            else
            {
                if (ack_data == ACK_ACTIVE_SUCCESS)
                {
                    m->setControl(true);
                    printf("active Success\n");
                }
                else
                {
                    printf("Error");
                }
            }
        }
        else
        {
            printf("Decode Error");
        }
    }
Esempio n. 2
0
    static void setControlCallBack(CoreAPI *This, Header *header, UserData userData){
        This->setControlCallback(This, header);


        MyObject *m = (MyObject *)userData;
        unsigned short ack_data = ACK_COMMON_NO_RESPONSE;

        if (header->length - EXC_DATA_SIZE <= 2)
        {
            memcpy((unsigned char *)&ack_data, ((unsigned char *)header) + sizeof(Header),
                   (header->length - EXC_DATA_SIZE));
        }
        else
        {
            printf("ACK is exception,seesion id %d,sequence %d\n",
                    header->sessionID, header->sequenceNumber);
        }

        switch (ack_data)
        {
            case ACK_SETCONTROL_RELEASE_SUCCESS:
                printf("relese control success\n");
                break;
            case ACK_SETCONTROL_OBTAIN_SUCCESS:
                printf("obtain control sucess\n");
                m->takeoff();
                break;
            default:
                printf("fail to setControl\n");
        }
    }
Esempio n. 3
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    MyObject* m = new MyObject();
    m->active();
    return a.exec();                // Start Event Loop(这是一个死循环)
}
Esempio n. 4
0
int main(int argc, char* argv[])
{
    QCoreApplication app(argc, argv);

    MyObject myObject;
    myObject.startWorkInAThread();

    return app.exec();
}
Esempio n. 5
0
int main(int argc, char** argv)
{
    MyObject obj;

    Handle handle1(&obj);

    Handle handle2 = handle1;

    cout << "ref object reference count: " << obj.ReferenceCount() << endl;
}
Esempio n. 6
0
MyObject* MyObject::getInstance(CCPoint point ,const char * spriteName,b2World *pMyworld,ObjectType type)
{
	MyObject* mySpriteNode = MyObject::create();
	mySpriteNode->m_pMyworld = pMyworld;
	mySpriteNode->initWithFile(spriteName);
	mySpriteNode->setAnchorPoint(ccp(0.5,0.5));
	mySpriteNode->setPosition(point);

	switch(type)
	{
	case WOOD:
		mySpriteNode->initPhySpriteWood();
		break;
	case IRON_V:
		mySpriteNode->initPhySpriteIronV();
		break;
	case IRON_H:
		mySpriteNode->initPhySpriteIronH();
		break;
	case TRIANGLE:
		mySpriteNode->initTriangle();
		break;
	case CIRCLE:
		mySpriteNode->initCircle();
		break;
	default: break;

	}
	
	return mySpriteNode;

}
Esempio n. 7
0
//--------------------------------------------------------------
void testApp::setup(){	
	ofBackground(255, 255, 255);
	
	MyObject *tempData = new MyObject(20, 70, 100, 500);
	
	for(int i=0; i < NUM_USERS; i++) {
		user[i].setData(tempData);			// users' internal pointer points to the same data, and retains it
		user[i].index = i+1;				// just arbitrary unique data per user for display
	}
	tempData->release();			// data is released from tempData, but is still in memory because its being used by the users
}
Esempio n. 8
0
    static void landCallBack(CoreAPI* This, Header* header, UserData userData){
        Flight::taskCallback(This, header, userData);

        MyObject* m = (MyObject*)userData;
        unsigned short ack_data;
        if (header->length - EXC_DATA_SIZE <= 2)
        {
            memcpy((unsigned char *)&ack_data, ((unsigned char *)header) + sizeof(Header),
                   (header->length - EXC_DATA_SIZE));

            m->setControl(false);
        }
    }
Esempio n. 9
0
 static NAN_METHOD(New) {
   if (info.IsConstructCall()) {
     double value = info[0]->IsUndefined() ? 0 : info[0]->NumberValue();
     MyObject *obj = new MyObject(value);
     obj->Wrap(info.This());
     info.GetReturnValue().Set(info.This());
   } else {
     const int argc = 1;
     v8::Local<v8::Value> argv[argc] = {info[0]};
     v8::Local<v8::Function> cons = Nan::New(constructor);
     info.GetReturnValue().Set(cons->NewInstance(argc, argv));
   }
 }
Esempio n. 10
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QThread cThread; //creat a thread
    MyObject cObject; //creat an instance of MyObject

    cObject.doSetup(cThread); //pass the thread to the MyObject setup
    cObject.moveToThread(&cThread); // take the object and move it to the thread

    cThread.start(); //start the thread

    return a.exec();
}
Esempio n. 11
0
void testMemoryProfilerTcpServer()
{
	MemoryProfiler& memoryProfiler = MemoryProfiler::singleton();
	memoryProfiler.setEnable(true);

	ProfilerServer server;
	server.listern();

	MyObject obj;
	Timer timer;

	LoopRunnable runnable1, runnable2, runnable3;
	Thread thread1(runnable1, false);
	thread1.setPriority(Thread::NormalPriority);
	Thread thread2(runnable2, false);
	thread2.setPriority(Thread::LowPriority);
//	Thread thread3(runnable3, false);
//	thread3.setPriority(Thread::LowPriority);

	while(true) {
		obj.functionA();

		// Inform the profiler we move to the next iteration
		memoryProfiler.nextFrame();

		server.accept();

		Profiler::mSleep(1);

		// Refresh and display the profiling result every 1 second
		if(timer.get().asSecond() > 1)
		{
			{	MemoryProfiler::Scope s("system(\"cls\")");
				::system("cls");
			}

			std::string s = makeReport(memoryProfiler);
			server.update(s + "\n\n");
			if(!server.connected)
				std::cout << "Waiting for connection on port 5000\n";
			std::cout << "Press any key to quit...\n\n";
			std::cout << s << std::endl;
			memoryProfiler.reset();
			timer.reset();

			if(_kbhit())
				return;
		}
	}
}
Esempio n. 12
0
 static NAN_METHOD(New) {
   if (info.IsConstructCall()) {
     double value = info[0]->IsNumber() ? To<double>(info[0]).FromJust() : 0;
     MyObject * obj = new MyObject(value);
     obj->Wrap(info.This());
     info.GetReturnValue().Set(info.This());
   } else {
     const int argc = 1;
     v8::Local<v8::Value> argv[argc] = {info[0]};
     v8::Local<v8::Function> cons = Nan::New(constructor());
     info.GetReturnValue().Set(
         Nan::NewInstance(cons, argc, argv).ToLocalChecked());
   }
 }
Esempio n. 13
0
  static NAN_METHOD(New) {
    NanScope();

    if (args.IsConstructCall()) {
      double value = args[0]->IsUndefined() ? 0 : args[0]->NumberValue();
      MyObject *obj = new MyObject(value);
      obj->Wrap(args.This());
      NanReturnThis();
    } else {
      const int argc = 1;
      v8::Local<v8::Value> argv[argc] = {args[0]};
      v8::Local<v8::Function> cons = NanNew(constructor);
      NanReturnValue(cons->NewInstance(argc, argv));
    }
  }
Esempio n. 14
0
void MyObject::New(const FunctionCallbackInfo<Value>& args) {
  Isolate* isolate = Isolate::GetCurrent();
  HandleScope scope(isolate);

  if (args.IsConstructCall()) {
    // Invoked as constructor: `new MyObject(...)`
    double value = args[0]->IsUndefined() ? 0 : args[0]->NumberValue();
    MyObject* obj = new MyObject(value);
    obj->Wrap(args.This());
    args.GetReturnValue().Set(args.This());
  } else {
    // Invoked as plain function `MyObject(...)`, turn into construct call.
    const int argc = 1;
    Local<Value> argv[argc] = { args[0] };
    Local<Function> cons = Local<Function>::New(isolate, constructor);
    args.GetReturnValue().Set(cons->NewInstance(argc, argv));
  }
}
Esempio n. 15
0
void PicDisp::generateStraightShape(const DisplayConf& dpc, MyObject& obj) const
{
    // needed anyway. used by the basic object
    g_smoothAllocator.clear();

    int i;
    for (i = 0; i < 3; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            placeSidePolygon(obj, -1, true, 1 + i, 1 + j);
        }
    }

    for (int b = 0; b < 16; ++b)
    {
        bool is1 = uncub(build[b].pnt.x, build[b].pnt.y); // the face number in this slot
        placeSidePolygon(obj, b, is1, build[b].pnt.x, build[b].pnt.y);
    }

    obj.vectorify();
    obj.clacNormals(dpc.bVtxNormals);
}
Esempio n. 16
0
bool MyRender::Draw()
{
  static float dfi = 0.02f;
  static float fi = 0.0f;
  static float radius = 30.0f;
  
  float dz = radius * (cos(fi + dfi) - cos(fi));
  float dx = radius * (sin(fi + dfi) - sin(fi));
  m_car->RotateY(dfi);
  m_car->Translate(dx, 0, dz);
  fi += dfi;
  if (fi > XM_2PI)
    fi -= XM_2PI;

  ConstantBuffer cb;

  m_camera->Update();
  XMMATRIX view = XMLoadFloat4x4(&(m_camera->GetViewMatrix()));

  // add all projectors info to constant buffer
  for (size_t i = 0, lightIndex = 0; i < m_scene->GetObjectsNumber(); i++)
  {
    MyObject *object = m_scene->GetObjectAt(i);
    for (size_t j = 0; j < object->GetProjectorLightsNumber(); j++, lightIndex++)
    {
      ProjectorLight *projector = object->GetProjectorAt(j);
      XMMATRIX projectorWorldMatrix = (XMLoadFloat4x4(&(object->GetWorldMatrix())));
      XMMATRIX projectorRotationMatrix = (XMLoadFloat4x4(&(object->GetRotationMatrix())));
      XMVECTOR tempPos = XMLoadFloat4(&(XMFLOAT4(projector->Pos.x, projector->Pos.y, projector->Pos.z, 1)));
      XMVECTOR tempDir = XMLoadFloat4(&(XMFLOAT4(projector->Direction.x, projector->Direction.y, projector->Direction.z, 1)));

      XMVECTOR projectorPos = XMVector4Transform(tempPos, projectorWorldMatrix);
      XMVECTOR projectorDir = XMVector4Transform(tempDir, projectorRotationMatrix);

      XMStoreFloat4(cb.vLightPos + lightIndex, projectorPos);
      XMStoreFloat4(cb.vLightDir + lightIndex, projectorDir);
	    cb.vLightColor[lightIndex] = projector->Color;
    }
  }
  // add all point lights info to constant buffer
  for (size_t i = 0, lightIndex = 0; i < m_scene->GetObjectsNumber(); i++)
  {
    MyObject *object = m_scene->GetObjectAt(i);
    for (size_t j = 0; j < object->GetPointLightsNumber(); j++, lightIndex++)
    {
      SimpleLight *bulb = object->GetPointLightAt(j);
      XMMATRIX bulbWorldMatrix = (XMLoadFloat4x4(&(object->GetWorldMatrix())));
      XMVECTOR tempPos = XMLoadFloat4(&(XMFLOAT4(bulb->Pos.x, bulb->Pos.y, bulb->Pos.z, 1)));

      XMVECTOR bulbPos = XMVector4Transform(tempPos, bulbWorldMatrix);

      XMStoreFloat4(cb.vBulbLightPos + lightIndex, bulbPos);
	    cb.vBulbLightColor[lightIndex] = bulb->Color;
    }
  }

  // add all directed lights info to constant buffer
  for (size_t i = 0, lightIndex = 0; i < m_scene->GetObjectsNumber(); i++)
  {
    MyObject *object = m_scene->GetObjectAt(i);
    for (size_t j = 0; j < object->GetDirectedLightsNumber(); j++, lightIndex++)
    {
      DirectedLight *dirLight = object->GetDirectedLightAt(j);
      XMMATRIX dirRotationMatrix = (XMLoadFloat4x4(&(object->GetRotationMatrix())));
      XMVECTOR tempDir = XMLoadFloat4(&(XMFLOAT4(dirLight->Dir.x, dirLight->Dir.y, dirLight->Dir.z, 1)));

      XMVECTOR bulbPos = XMVector4Transform(tempDir, dirRotationMatrix);

      XMStoreFloat4(cb.vDirectedLightDir + lightIndex, bulbPos);
	    cb.vDirectedLightColor[lightIndex] = dirLight->Color;
    }
  }

  cb.isLightEnabled[0] = m_enableProjectorLight;
  cb.isLightEnabled[1] = m_enablePointLight;
  cb.isLightEnabled[2] = m_enableDirectedLight;
  cb.isLightEnabled[3] = 0;

  for (size_t idx = 0; idx < m_scene->GetObjectsNumber(); idx++)
  {
    MyObject *object = m_scene->GetObjectAt(idx);

    /****************************************************/

    D3D11_BUFFER_DESC bd;
    RtlZeroMemory(&bd, sizeof(bd));
    bd.Usage = D3D11_USAGE_DEFAULT;
    bd.ByteWidth = sizeof(SimpleVertex) * object->GetVerticesNumber();
	  bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
	  bd.CPUAccessFlags = 0;

    D3D11_SUBRESOURCE_DATA data;
    RtlZeroMemory(&data, sizeof(data));
    data.pSysMem = object->GetVertices();

    HRESULT hr = m_pd3dDevice->CreateBuffer(&bd, &data, &m_pVertexBuffer);
    if (FAILED(hr))
    {
      Log::Get()->Err("CreateBuffer error for vertex buffer.");
      return false;
    }
    UINT stride = sizeof(SimpleVertex);
	  UINT offset = 0;

    m_pImmediateContext->IASetVertexBuffers(0, 1, &m_pVertexBuffer, &stride, &offset);
  
    bd.Usage = D3D11_USAGE_DEFAULT;
    bd.ByteWidth = sizeof(UINT) * object->GetIndicesNumber();
	  bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
	  bd.CPUAccessFlags = 0;
	  data.pSysMem = object->GetIndices();
	  hr = m_pd3dDevice->CreateBuffer(&bd, &data, &m_pIndexBuffer);
	  if(FAILED(hr))
    {
      Log::Get()->Err("CreateBuffer error for torus.");
		  return false;
    }
    m_pImmediateContext->IASetIndexBuffer(m_pIndexBuffer, DXGI_FORMAT_R32_UINT, 0);
    m_pImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

    /****************************************************/
    XMMATRIX world = XMLoadFloat4x4(&(object->GetWorldMatrix()));

    cb.mWorld = XMMatrixTranspose(world);
    cb.mView = XMMatrixTranspose(view);
	  cb.mProjection = XMMatrixTranspose(m_Projection);
    cb.vOutputColor = XMFLOAT4(0, 0, 0, 0);
	  m_pImmediateContext->UpdateSubresource(m_pConstantBuffer, 0, NULL, &cb, 0, 0);
  
	  m_pImmediateContext->VSSetShader(m_pVertexShader, NULL, 0);
	  m_pImmediateContext->VSSetConstantBuffers( 0, 1, &m_pConstantBuffer);
    if (object == m_sun) // absolutely black body
	    m_pImmediateContext->PSSetShader(m_pPixelShaderSolid, NULL, 0);
    else
      m_pImmediateContext->PSSetShader(m_pPixelShader, NULL, 0);
	  m_pImmediateContext->PSSetConstantBuffers( 0, 1, &m_pConstantBuffer);
    m_pImmediateContext->DrawIndexed(object->GetIndicesNumber(), 0, 0);

    _RELEASE(m_pVertexBuffer);
    _RELEASE(m_pIndexBuffer);
  }
	return true;
}
Esempio n. 17
0
void PicDisp::placeSidePolygon(MyObject& obj, int b, bool is1, int x, int y) const
{
    static Vec3 pnti1[4], pnti2[4], pntiA[4], pntiB[4], pntiC[4], pntiD[4];

    Vec3 shpp[4];
    TexAnchor ancs1[4], ancs2[4], baseancf[4], baseancs[4], ancsR1[4], ancsR2[4], ancsR3[4], ancsR4[4];
    int i;

    double bx, by, rbx, rby; // makers of texture coordinates.. fronts and side-patches

    rbx = bx = double(x)/5.0;
    rby = by = double(y)/5.0;

/*	const PicGroupDef *mygrp = m_pdef->mygrp();
    if (mygrp->drawtype == DRAW_TEXTURE_IMAGE)
    {
        rbx = 0.0; rby = 0.0; // side patches of this has their own coordinates
    }
*/

    baseancf[0] = TexAnchor(bx, by);
    baseancf[1] = TexAnchor(bx + 0.2, by);
    baseancf[2] = TexAnchor(bx + 0.2, by + 0.2);
    baseancf[3] = TexAnchor(bx, by + 0.2);
    
    baseancs[0] = TexAnchor(rbx, rby);
    baseancs[1] = TexAnchor(rbx + 0.2, rby);
    baseancs[2] = TexAnchor(rbx + 0.2, rby + 0.2);
    baseancs[3] = TexAnchor(rbx, rby + 0.2);

/*	if (mygrp->drawtype == DRAW_TEXTURE_IMAGE)
    { // rescale it since the texture is a big one
        double xfact = mygrp->sideTex->img.width(), yfact = mygrp->sideTex->img.height();
        for(i = 0; i < 4; ++i) // pntn == 4
        {
            baseancs[i].x += ((double)(mygrp->sideTexX) / xfact);
            baseancs[i].y += ((double)(mygrp->sideTexY) / yfact);
        }
    }
*/
    Texture *tex = nullptr; //m_pdef->tex;

    ancs1[0] = baseancf[0]; ancs2[0] = baseancf[3]; 
    ancs1[1] = baseancf[1]; ancs2[1] = baseancf[2]; 
    ancs1[2] = baseancf[2]; ancs2[2] = baseancf[1];
    ancs1[3] = baseancf[3]; ancs2[3] = baseancf[0];

    shpp[0] = Vec3(x, y, 0); 	 shpp[1] = Vec3(x+1, y, 0);
    shpp[2] = Vec3(x+1, y+1, 0); shpp[3] = Vec3(x, y+1, 0);
    PlaceInto(4, shpp, pnti1, pnti2, PLACE_NORM);

    if (is1)
    { // polys that make the flat surface.
        obj.addPoly(pnti1, ancs1, nullptr); //if its an out of place, it's textured
        obj.addPoly(pnti2, ancs2, tex);
    }

    /////////////////////// side patches //////////////////
    if (b < 0)
        return; // enough of this shananigan, we're not on the sides.

    if (false) //mygrp->drawtype == DRAW_TEXTURE_IMAGE)
    {
        for (i = 0; i < 4; ++i)
        {
            ancsR1[half_orient_data[3][i]] = baseancs[i];
            ancsR2[half_orient_data[3][i]] = baseancs[i];

            ancsR3[half_orient_data[0][i]] = baseancs[i];
            ancsR4[half_orient_data[1][i]] = baseancs[i];
        }
    }
    else
    {  // randomly turned...
        for(i = 0; i < 4; ++i)
        {
            ancsR3[i] = ancsR1[i] = baseancs[3-i];
            ancsR4[i] = ancsR2[i] = baseancs[i];
        }
    }

    shpp[0] = Vec3(x, y, 0);   shpp[1] = Vec3(x, y, 1);
    shpp[2] = Vec3(x+1, y, 1); shpp[3] = Vec3(x+1, y, 0);
    PlaceInto(4, shpp, pntiA, pntiB, PLACE_X);

    shpp[0] = Vec3(x, y, 0);   shpp[1] = Vec3(x, y+1, 0);
    shpp[2] = Vec3(x, y+1, 1); shpp[3] = Vec3(x, y, 1);
    PlaceInto(4, shpp, pntiC, pntiD, PLACE_Y);

    int polyf = 0;
    if (is1)
    {
        if (build[b].corner)
            polyf |= build[b].pold.in1 | build[b].pold.in0;
        else
            polyf |= build[b].pold.in1;
        
        int prevb = (b == 0)?15:(b - 1), nextb = b + 1;

        if (uncub(build[prevb].pnt.x, build[prevb].pnt.y) != is1)
            polyf |= build[b].sds.prev0;
        if (uncub(build[nextb].pnt.x, build[nextb].pnt.y) != is1)
            polyf |= build[b].sds.next0;
    }
    else if (!build[b].corner)
    {
        polyf |= build[b].pold.in0;
    }

    Texture* sideTex = nullptr; // mygrp->sideTex

    if (polyf & POLY_A) obj.addPoly(pntiA, ancsR1, sideTex); //if its an out of place, it's textured
    if (polyf & POLY_B) obj.addPoly(pntiB, ancsR2, sideTex);
    if (polyf & POLY_C) obj.addPoly(pntiC, ancsR3, sideTex); //if its an out of place, it's textured
    if (polyf & POLY_D) obj.addPoly(pntiD, ancsR4, sideTex);
    std::swap(pntiA[1], pntiA[3]); std::swap(ancsR1[1], ancsR1[3]);
    std::swap(pntiB[1], pntiB[3]); std::swap(ancsR2[1], ancsR2[3]);
    std::swap(pntiC[1], pntiC[3]); std::swap(ancsR3[1], ancsR3[3]);
    std::swap(pntiD[1], pntiD[3]); std::swap(ancsR4[1], ancsR4[3]);
    if (polyf & POLY_UA) obj.addPoly(pntiA, ancsR1, sideTex); //if its an out of place, it's textured
    if (polyf & POLY_UB) obj.addPoly(pntiB, ancsR2, sideTex);
    if (polyf & POLY_UC) obj.addPoly(pntiC, ancsR3, sideTex); //if its an out of place, it's textured
    if (polyf & POLY_UD) obj.addPoly(pntiD, ancsR4, sideTex);


}
Esempio n. 18
0
void fyxPart(std::vector<Object*>* objectList)
{
	MyObject *MyObjectOne = new MyObject;
	objectList->push_back(MyObjectOne);

    MyCylinder * CylinderOne = new MyCylinder();
    CylinderOne->color = Vector3(0.8,0.9,0.6);
	CylinderOne->location = Vector3(60,5,-3);
	CylinderOne->rotate = Vector3(0,90,0);
	MyObjectOne->addChild(CylinderOne);

	MyObject *FrontWall = new MyObject;
  	FrontWall->location = Vector3(100.0,0.0,0.0);
  	MyObjectOne->addChild(FrontWall);
  	MyObject *BackWall = new MyObject;
  	BackWall->location = Vector3(0.0,0.0,-100.0);
  	BackWall->rotate = Vector3(0.0,180.0,0.0);
  	MyObjectOne->addChild(BackWall);
  	MyObject *LeftWall = new MyObject;
  	LeftWall->rotate = Vector3(0.0,270.0,0.0);
  	MyObjectOne->addChild(LeftWall);
	MyObject *RightWall = new MyObject;
  	RightWall->location = Vector3(100.0,0.0,-100.0);
  	RightWall->rotate = Vector3(0.0,90.0,0.0);
  	MyObjectOne->addChild(RightWall);
  	MyObject *TopWall = new MyObject;
  	TopWall->location = Vector3(100.0,100.0,0.0);
  	TopWall->rotate = Vector3(270.0,0.0,0.0);
  	MyObjectOne->addChild(TopWall);
  	MyObject *BottomWall = new MyObject;
  	BottomWall->location = Vector3(100.0,0.0,-100.0);
  	BottomWall->rotate = Vector3(90.0,0.0,0.0);
  	MyObjectOne->addChild(BottomWall);

  	NewWall *AllWall = new NewWall;
  	AllWall->location = Vector3(-50.0,50.0,0.0);
  	AllWall->size = Vector3(100.0,100.0,2.0);
  	FrontWall->addChild(AllWall);
  	BackWall->addChild(AllWall);
  	LeftWall->addChild(AllWall);
  	RightWall->addChild(AllWall);

	Top * Topt = new Top;
  	Topt->location = Vector3(-50.0,50.0,0.0);
  	Topt->size = Vector3(100.0,100.0,1.0);
  	TopWall->addChild(Topt);

  	Bottom * Bottomt = new Bottom;
  	Bottomt->location = Vector3(-50.0,50.0,0.0);
  	Bottomt->size = Vector3(100.0,100.0,1.0);
  	BottomWall->addChild(Bottomt);

//  	MyObject *CompleteDoor = new MyObject;
//  	CompleteDoor->location = Vector3(50.0,10.0,-98.4);
//  	MyObjectOne->addChild(CompleteDoor);
//  	Door *MyDoor = new Door;
//  	MyDoor->location = Vector3(0.0,0.0,0.0);
//  	MyDoor->size = Vector3(12.0,20.0,1.0);
//  	CompleteDoor->addChild(MyDoor);
//  	Out *DoorOut = new Out;
//  	DoorOut->color = Vector3(0.0,0.0,0.0);
//  	DoorOut->location = Vector3(0.0,0.0,-1.0);
//  	DoorOut->size = Vector3(12.0,20.0,1.0);
//  	CompleteDoor->addChild(DoorOut);
//  	Cube *Doorbar1 = new Cube;
//  	Doorbar1->color = Vector3(0.501,0.2,0);
//  	Doorbar1->location = Vector3(-6.0,0.0,0.0);
//  	Doorbar1->size = Vector3(1.0,21.0,2.0);
//  	CompleteDoor->addChild(Doorbar1);
//  	Cube *Doorbar2 = new Cube;
//  	Doorbar2->color = Vector3(0.501,0.2,0);
//  	Doorbar2->location = Vector3(6.0,0.0,0.0);
//  	Doorbar2->size = Vector3(1.0,21.0,2.0);
//  	CompleteDoor->addChild(Doorbar2);
//  	Cube *Doorbar3 = new Cube;
//  	Doorbar3->color = Vector3(0.501,0.2,0);
//  	Doorbar3->location = Vector3(0.0,10.0,0.0);
//  	Doorbar3->size = Vector3(12.0,1.0,2.0);
//  	CompleteDoor->addChild(Doorbar3);
}
Esempio n. 19
0
//--------------------------------------------------------------
void testApp::draw()
{
	myObject1.draw();
}
Esempio n. 20
0
 static NAN_METHOD(GetHandle) {
   MyObject* obj = ObjectWrap::Unwrap<MyObject>(info.This());
   info.GetReturnValue().Set(obj->handle());
 }
Esempio n. 21
0
	//CCDictionary* dict = NULL;
	//CCObject *pObject = NULL;
	CCARRAY_FOREACH(pChildrenArray,pObject)
	{
		dict = (CCDictionary *)pObject;
		if(!dict)
			break;
		const char* key = "name";
		CCString* name = (CCString*)dict->objectForKey(key);
		if(name->isEqual(CCString::create("fire")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();
			addFire(ccp(x,y));
		}else if(name->isEqual(CCString::create("monster")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();
			key = "plistname";
			CCString* temp = ((CCString*)dict->objectForKey(key));
			string* plistname = new string(temp->getCString());
			plistname->append(".plist");
			string* spritename = new string(temp->getCString());
			spritename->append("_%d.png");

			MySprite* sprite =	MySprite::getInstance(ccp(x,y),plistname->c_str(),spritename->c_str(),m_pMyworld);		

			key = "enemy";
		    sprite->setType(((CCString*)dict->objectForKey(key))->isEqual(CCString::create("true")));//设置 敌人

			sprite->setTag(m_iMosterSpriteTag);
	

			if (((CCString*)dict->objectForKey(key))->isEqual(CCString::create("true"))){//如果是敌人
				m_iResuduoMonsterNum++;
				sprite->setCallbackFunc(this,callfunc_selector(GameSceneLayer::gameVictory));
			}else{
				sprite->setCallbackFunc(this,callfunc_selector(GameSceneLayer::gameFaild));
			}

			this->addChild(sprite);
			delete plistname;
			delete spritename;
		}else if(name->isEqual(CCString::create("wood")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();
			key = "sprite_name";
			CCString* sprite_name= (CCString*)dict->objectForKey(key);
			MyObject* sprite =	MyObject::getInstance(ccp(x,y),sprite_name->getCString(),m_pMyworld,MyObject::WOOD);		
			this->addChild(sprite);
		}else if(name->isEqual(CCString::create("iron_v")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();

			key = "bottom";
			int bottom = ((CCString*)dict->objectForKey(key))->intValue();
			key = "speed";
			int speed = ((CCString*)dict->objectForKey(key))->intValue();
			key = "top";
			int top = ((CCString*)dict->objectForKey(key))->intValue();

			MyObject* sprite =	MyObject::getInstance(ccp(x,y),"iron_v.png",m_pMyworld,MyObject::IRON_V);	
			sprite->setProperties(ccp(0,speed),ccp(top,bottom),ccp(0,0));
			this->addChild(sprite);
		}else if(name->isEqual(CCString::create("iron_h")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();

			key = "left";
			int left = ((CCString*)dict->objectForKey(key))->intValue();
			key = "speed";
			int speed = ((CCString*)dict->objectForKey(key))->intValue();
			key = "right";
			int right = ((CCString*)dict->objectForKey(key))->intValue();

			MyObject* sprite =	MyObject::getInstance(ccp(x,y),"iron_h.png",m_pMyworld,MyObject::IRON_H);	
			sprite->setProperties(ccp(speed,0),ccp(0,0),ccp(left,right));
			this->addChild(sprite);
		}else if(name->isEqual(CCString::create("triangle")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();
			MyObject* sprite =	MyObject::getInstance(ccp(x,y),"triangle.png",m_pMyworld,MyObject::TRIANGLE);		
			this->addChild(sprite);
		}else if(name->isEqual(CCString::create("circle")))
		{
			key = "x";
			int x = ((CCString*)dict->objectForKey(key))->intValue();
			key = "y";
			int y = ((CCString*)dict->objectForKey(key))->intValue();
			key = "sprite_name";
			CCString* sprite_name= (CCString*)dict->objectForKey(key);
			MyObject* sprite =	MyObject::getInstance(ccp(x,y),sprite_name->getCString(),m_pMyworld,MyObject::CIRCLE);		
			this->addChild(sprite);
		}	

	}
Esempio n. 22
0
int Foo(char* bar) {
    MyObject* mo = new MyObject();
    printf("%d", SomeMethodCall(mo->ToString()));
}