ColorSampleOfPicker::ColorSampleOfPicker(Actor *parent) : Actor(getRandomName(), parent, CANVAS, 104, 32) { KrRGBA *pixels = getCanvasResource()->Pixels(), color; color.Set(255, 255, 255, 255); for(int i = 0; i < Width(); i++) { for(int j = 0; j < Height(); j++) { pixels[ j*Width() + i ] = color; } } }
Giant::Giant(bool pGender, Entity* pFather, Entity* pMother,Entity* pBrother, Genome* pGenome, int pLife) { _Gender = pGender; _Father = pFather; _Mother = pMother; _Brother = pBrother; _Genome = pGenome; _Age = 0; _Name = getRandomName(); _Experience = 0; _Life = pLife; _Superstition = 0 ;//La supersticion debería heredarla de la madre/padre. _ID = Constants::getIDCounter(); }
void RegisterScene::onEnter(){ BaseScene::onEnter(); GraphicUtils::drawString(this, "输入姓名", CommonUtils::getScreenWidth() / 2 , CommonUtils::getScreenHeight() - 300, getSystemColor(COLOR_KEY_WHITE), TEXT_ALIGN_CENTER_MIDDLE, 40); CCSize editBoxSize = CCSizeMake( 200, 32 ); editBox = CCEditBox::create( editBoxSize, CCScale9Sprite::create("img/base_panel.png")); // Positionは画面の遥か外側のためccp(1000,1000) editBox->setPosition( ccp( 2000, 2000 ) ); editBox->setText( "" ); editBox->setMaxLength(8); editBox->setReturnType( kKeyboardReturnTypeDefault ); editBox->setInputMode( kEditBoxInputModeSingleLine ); editBox->setDelegate(this); editBox->setVisible( false ); this->addChild(editBox); // 画像でかぶせる editBoxSprite = GameSprite::init( "img/handle_name_frame.png" ); editBoxSprite->setAnchorPoint(ccp(0.5,1)); editBoxSprite->setSize( 400, 64 ); editBoxSprite->setPosition( CommonUtils::getScreenWidth() / 2, 960); this->addChild(editBoxSprite); m_confirmButton = CCControlButton::create("确认", DEFAULT_FONT_NAME, 40); m_confirmButton->setPosition(CommonUtils::getScreenWidth() / 2, 500); this->addChild(m_confirmButton); m_confirmButton->addTargetWithActionForControlEvents(this, cccontrol_selector(RegisterScene::create_user), CCControlEventTouchDown); m_randomButton = CCControlButton::create("随机姓名", DEFAULT_FONT_NAME, 40); m_randomButton->setPosition(CommonUtils::getScreenWidth() / 2, 1000); this->addChild(m_randomButton); m_randomButton->addTargetWithActionForControlEvents(this, cccontrol_selector(RegisterScene::getRandomName), CCControlEventTouchDown); float nx = CommonUtils::getScreenWidth() / 2 - 143; float ny = 980; userName = GraphicUtils::drawString( this, "", nx, ny, 200, 32, ccc3(255,255,255), TEXT_ALIGN_LEFT_TOP, 40 ); getRandomName(NULL, NULL); }
ColorSample::ColorSample(Actor *parent, int x, int y, int w, int h, bool _bEditControls) : Actor(getRandomName(), parent, CANVAS, w, _bEditControls?56:h) { rEdit = gEdit = bEdit = NULL; setColor(255, 255, 255); SetPos(x, y); if(_bEditControls) { Text *text; text = AddText(" Red: ", Width() + 5, 0); rEdit = AddEditBox(text->Right(), text->Top(), 48); rEdit->SetNumeric(0, 255, 1); text = AddText("Green: ", text->Left(), rEdit->Down() + 2); gEdit = AddEditBox(text->Right(), text->Top(), 48); gEdit->SetNumeric(0, 255, 1); text = AddText(" Blue: ", text->Left(), gEdit->Down() + 2); bEdit = AddEditBox(text->Right(), text->Top(), 48); bEdit->SetNumeric(0, 255, 1); } }
bool PlaneNodeProcessor::processNode(DOMElement *nodeElem, bool loadGameObjects) { if (!hasNodeName(nodeElem, "plane")) { return false; } Ogre::String entName = getAttributeValueAsStdString(nodeElem, "name"); LOG_DEBUG(Logger::RULES, "Processing plane node " + entName); if(entName=="") { entName = getRandomName("Plane"); } Quaternion orientation(Quaternion::IDENTITY); Vector3 position(Vector3::ZERO); Vector2 scale(1,1); DOMElement* oriElem = getChildNamed(nodeElem, "rotation"); if (oriElem != NULL) { orientation = processQuaternion(oriElem); } else { LOG_WARNING(Logger::RULES, "No orientation given for plane, used Identity"); } DOMElement* posElem = getChildNamed(nodeElem, "position"); if (posElem != NULL) { position = processVector3(posElem); } else { LOG_WARNING(Logger::RULES, "No position given for plane, used (0,0,0)"); } DOMElement* scaleElem = getChildNamed(nodeElem, "scale"); if (posElem != NULL) { scale = processVector2(scaleElem); } else { LOG_WARNING(Logger::RULES, "No scale given for plane, used (0,0)"); } while(!MeshManager::getSingleton().getByName(entName).isNull()) { entName = getRandomName("Plane"); } SceneNode* node = getRootSceneNode()->createChildSceneNode(entName + "Node", position, orientation); MovablePlane* plane = new MovablePlane(entName + "Plane"); plane->d = 0; plane->normal = Vector3::UNIT_Y; MeshManager::getSingleton().createPlane(entName + "Mesh", "custom", *plane, scale.x, scale.y, 10, 10, true, 1, 1, 1, Vector3::UNIT_Z); Entity* ent = CoreSubsystem::getSingleton().getWorld()->getSceneManager()->createEntity(entName, entName + "Mesh"); LOG_DEBUG(Logger::RULES, " Loaded plane "+entName); node->attachObject(ent); node->attachObject(plane); //node->scale(scale.x,1,scale.y); createCollision(ent, getChildNamed(nodeElem, "physicsproxy")); DOMElement* materialElem = getChildNamed(nodeElem, "material"); if(materialElem) { if(getChildNamed(nodeElem, "renderToTexture")) { Ogre::String matName = getAttributeValueAsStdString(materialElem, "name"); MaterialPtr material = static_cast<MaterialPtr>(MaterialManager::getSingleton().getByName(matName))->clone(matName + entName); createRenderToTextures(ent, plane, material, getChildNamed(nodeElem, "renderToTexture")); ent->setMaterialName(matName + entName); } else ent->setMaterialName(getAttributeValueAsStdString(materialElem, "name")); } else { LOG_WARNING(Logger::RULES, "No material given for plane "+entName); } return true; }