void SE_NetDataCommand::handle(SE_TimeMS realDelta, SE_TimeMS simulateDelta) { SE_ASSERT(mMsg->len >= 3); int id = mMsg->data[0]; unsigned short dataLen = 0; memcpy(&dataLen, mMsg->data + 1, 2); dataLen = SE_Util::net2HostInt16(dataLen); int realDataLen = dataLen - 3; std::string str; if(realDataLen > 0) { str.assign((char*)mMsg->data + 3, realDataLen); } for(int i = 0 ; i < mMsg->len ; i++) { LOGI("%d\n", mMsg->data[i]); } LOGI("### msg len = %d , str = %s ###\n", mMsg->len, str.c_str()); if(id == 0 && str.size() > 0) { SE_ImageUnit iu; SE_ResourceManager* resourceManager = SE_GET_RESOURCEMANAGER(); SE_ImageData* imageData = resourceManager->loadImageWithFullPath(str.c_str()); if(!imageData) { LOGI("can not load image\n"); return; } iu.imageDataID = str.c_str(); iu.imageRect.x = 0; iu.imageRect.y = 0; iu.imageRect.width = imageData->getWidth(); iu.imageRect.height = imageData->getHeight(); SE_ImageElement* imageElement = new SE_ImageElement(""); imageElement->setBaseColor(iu); SE_SceneManager* sceneManager = SE_Application::getInstance()->getSceneManager(); SE_Scene* scene = new SE_2DScene; scene->setBackground(SE_Vector4f(1.0f, 1.0f, 1.0f, 1.0f)); scene->setBound(480, 800); scene->setRootElement(imageElement); SE_SceneID sceneID = sceneManager->add(scene); //create camera SE_Camera* camera = SE_Camera::create2DSceneCamera(480, 800); SE_CameraManager* cameraManager = SE_Application::getInstance()->getCameraManager(); SE_CameraID cameraID = cameraManager->add(camera); scene->setCamera(cameraID); //end sceneManager->show(sceneID); } else { } }
static void se_createScene(JNIEnv* env, jobject obj) { jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID); const char* sceneName8 = env->GetStringUTFChars(sceneName, 0); SE_Scene* scene = findScene(sceneName8); if (!scene) { scene = new SE_Scene(sceneName8); SE_Application::getInstance()->getSceneManager()->pushBack(SE_FRAMEBUFFER_SCENE, scene); SE_Camera* camera = new SE_Camera(); scene->inflate("assets/base/scene_resource.xml"); scene->setCamera(camera); } env->ReleaseStringUTFChars(sceneName, sceneName8); }