void QWmpPlayerControl::playStateChangeEvent(long state) { switch (state) { case wmppsUndefined: m_state = QMediaPlayer::StoppedState; m_status = QMediaPlayer::UnknownMediaStatus; scheduleUpdate(StatusChanged | StateChanged); break; case wmppsStopped: if (m_state != QMediaPlayer::StoppedState) { m_state = QMediaPlayer::StoppedState; scheduleUpdate(StateChanged); if (m_status != QMediaPlayer::EndOfMedia) { m_status = QMediaPlayer::LoadedMedia; scheduleUpdate(StatusChanged); } } break; case wmppsPaused: if (m_state != QMediaPlayer::PausedState && m_status != QMediaPlayer::BufferedMedia) { m_state = QMediaPlayer::PausedState; m_status = QMediaPlayer::BufferedMedia; scheduleUpdate(StatusChanged | StateChanged); } else if (m_state != QMediaPlayer::PausedState) { m_state = QMediaPlayer::PausedState; scheduleUpdate(StateChanged); } else if (m_status != QMediaPlayer::BufferedMedia) { m_status = QMediaPlayer::BufferedMedia; scheduleUpdate(StatusChanged); } break; case wmppsPlaying: case wmppsScanForward: case wmppsScanReverse: if (m_state != QMediaPlayer::PlayingState && m_status != QMediaPlayer::BufferedMedia) { m_state = QMediaPlayer::PlayingState; m_status = QMediaPlayer::BufferedMedia; scheduleUpdate(StatusChanged | StateChanged); } else if (m_state != QMediaPlayer::PlayingState) { m_state = QMediaPlayer::PlayingState; scheduleUpdate(StateChanged); } else if (m_status != QMediaPlayer::BufferedMedia) { m_status = QMediaPlayer::BufferedMedia; scheduleUpdate(StatusChanged); } if (m_state != QMediaPlayer::PlayingState) { m_state = QMediaPlayer::PlayingState; scheduleUpdate(StateChanged); } if (m_status != QMediaPlayer::BufferedMedia) { m_status = QMediaPlayer::BufferedMedia; scheduleUpdate(StatusChanged); } break; case wmppsBuffering: case wmppsWaiting: if (m_status != QMediaPlayer::StalledMedia && m_state != QMediaPlayer::StoppedState) { m_status = QMediaPlayer::StalledMedia; scheduleUpdate(StatusChanged); } break; case wmppsMediaEnded: if (m_status != QMediaPlayer::EndOfMedia && m_state != QMediaPlayer::StoppedState) { m_state = QMediaPlayer::StoppedState; m_status = QMediaPlayer::EndOfMedia; scheduleUpdate(StatusChanged | StateChanged); } break; case wmppsTransitioning: break; case wmppsReady: if (m_status != QMediaPlayer::LoadedMedia) { m_status = QMediaPlayer::LoadedMedia; scheduleUpdate(StatusChanged); } if (m_state != QMediaPlayer::StoppedState) { m_state = QMediaPlayer::StoppedState; scheduleUpdate(StateChanged); } break; case wmppsReconnecting: if (m_status != QMediaPlayer::StalledMedia && m_state != QMediaPlayer::StoppedState) { m_status = QMediaPlayer::StalledMedia; scheduleUpdate(StatusChanged); } break; default: break; } }
void MouseDialogNavigationTool::frame(void) { /* Update the current mouse position: */ Point newCurrentPos=calcScreenPos(); if(currentPos!=newCurrentPos) { currentPos=newCurrentPos; lastMoveTime=getApplicationTime(); } if(factory->interactWithWidgets) { /* Update the GUI interactor: */ GUIInteractor::updateRay(); GUIInteractor::move(); } /* Act depending on this tool's current state: */ if(NavigationTool::isActive()) { if(spinning) { /* Calculate incremental rotation: */ rotation.leftMultiply(NavTrackerState::rotate(NavTrackerState::Rotation::rotateScaledAxis(spinAngularVelocity*getFrameTime()))); NavTrackerState t=preScale; t*=rotation; t*=postScale; setNavigationTransformation(t); /* Request another frame: */ scheduleUpdate(getApplicationTime()+1.0/125.0); } else { switch(navigationMode) { case ROTATING: { /* Calculate the rotation position: */ Vector offset=(lastRotationPos-screenCenter)+rotateOffset; /* Calculate mouse displacement vector: */ Point rotationPos=currentPos; Vector delta=rotationPos-lastRotationPos; lastRotationPos=rotationPos; /* Calculate incremental rotation: */ Vector axis=Geometry::cross(offset,delta); Scalar angle=Geometry::mag(delta)/factory->rotateFactor; if(angle!=Scalar(0)) rotation.leftMultiply(NavTrackerState::rotate(NavTrackerState::Rotation::rotateAxis(axis,angle))); NavTrackerState t=preScale; t*=rotation; t*=postScale; setNavigationTransformation(t); break; } case PANNING: { /* Update the navigation transformation: */ NavTrackerState t=NavTrackerState::translate(currentPos-motionStart); t*=preScale; setNavigationTransformation(t); break; } case DOLLYING: { /* Calculate the current dollying direction: */ Scalar viewport[4]; ONTransform screenT=getMouseScreenTransform(mouseAdapter,viewport); Vector dollyingDirection=screenT.transform(factory->screenDollyingDirection); /* Update the navigation transformation: */ Scalar dollyDist=((currentPos-motionStart)*dollyingDirection)/factory->dollyFactor; NavTrackerState t=NavTrackerState::translate(dollyDirection*dollyDist); t*=preScale; setNavigationTransformation(t); break; } case SCALING: { /* Calculate the current scaling direction: */ Scalar viewport[4]; ONTransform screenT=getMouseScreenTransform(mouseAdapter,viewport); Vector scalingDirection=screenT.transform(factory->screenScalingDirection); /* Update the navigation transformation: */ Scalar scale=((currentPos-motionStart)*scalingDirection)/factory->scaleFactor; NavTrackerState t=preScale; t*=NavTrackerState::scale(Math::exp(scale)); t*=postScale; setNavigationTransformation(t); break; } } } } }
void TextField::onEnter() { Widget::onEnter(); scheduleUpdate(); }
// Turn the display on/off (quickly) void VGALiquidCrystal::noDisplay() { display_on = false; scheduleUpdate(); }
// These commands scroll the display without changing the RAM void VGALiquidCrystal::scrollDisplayLeft(void) { shiftChars++; scheduleUpdate(); }
// on "init" you need to initialize your instance bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); /* auto icon = Sprite::create("CloseNormal.png"); addChild(icon); icon->setPosition(visibleSize/2); schedule([icon](float f){ auto size=icon->getContentSize(); CCLOG("SIZE:%f %f",size.width,size.height); },"test"); Vector<Label*> vec; auto lable1= Label::create(); auto lable2= Label::create(); lable1->setString("Lable 1"); lable2->setString("Lable 2"); lable1->setSystemFontSize(50); lable2->setSystemFontSize(50); vec.pushBack(lable1); vec.pushBack(lable2); int i=0; for (auto label:vec) { i++; label->setPosition(Vec2(visibleSize.width/2, i*100)); addChild(label); } cocos2d::Map<std::string, Label*> map; auto lable1= Label::create(); auto lable2= Label::create(); lable1->setString("Lable 1"); lable2->setString("Lable 2"); lable1->setSystemFontSize(50); lable2->setSystemFontSize(50); lable1->setPosition(Vec2(visibleSize.width/2, 1*100)); lable2->setPosition(Vec2(visibleSize.width/2, 2*100)); map.insert("lable1", lable1); map.insert("lable2", lable2); addChild(map.at("lable1")); Value value1= Value("abc"); Value value2= Value(123); Value value3= Value(true); CCLOG("%s %d %s",value1.asString().c_str(),value2.asInt(),value3.asBool()==true?"true":"false"); CCLOG("%s %s %s",value1.asString().c_str(),value2.asString().c_str(),value3.asString().c_str()); Value value4= Value::Null; value4=value1; value4=value2; value4=value3; ValueVector verctor; verctor.push_back(Value("hello")); verctor.push_back(value1); verctor.push_back(value2); for (auto v:verctor) { CCLOG("Verctor %s",v.asString().c_str()); } ValueMap map; map["a"]=value2; map["b"]=value3; for (auto m:map) { CCLOG("map %s %s",m.first.c_str(),m.second.asString().c_str()); } cocos2d::Value intVar(40); CCLOG("%d ",intVar.asInt()); */ schedule(schedule_selector(HelloWorld::addBall),0.1f); scheduleUpdate(); return true; }
void CCLayerPanZoom::onEnter() { CCLayer::onEnter(); scheduleUpdate(); }
Box2DTestLayer::Box2DTestLayer() { setIsTouchEnabled( true ); setIsAccelerometerEnabled( true ); CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); //UXLOG(L"Screen width %0.2f screen height %0.2f",screenSize.width,screenSize.height); // Define the gravity vector. b2Vec2 gravity; gravity.Set(0.0f, -10.0f); // Do we want to let bodies sleep? bool doSleep = true; // Construct a world object, which will hold and simulate the rigid bodies. world = new b2World(gravity); world->SetAllowSleeping(doSleep); world->SetContinuousPhysics(true); /* m_debugDraw = new GLESDebugDraw( PTM_RATIO ); world->SetDebugDraw(m_debugDraw); uint flags = 0; flags += b2DebugDraw::e_shapeBit; flags += b2DebugDraw::e_jointBit; flags += b2DebugDraw::e_aabbBit; flags += b2DebugDraw::e_pairBit; flags += b2DebugDraw::e_centerOfMassBit; m_debugDraw->SetFlags(flags); */ // Define the ground body. b2BodyDef groundBodyDef; groundBodyDef.position.Set(screenSize.width/2/PTM_RATIO, screenSize.height/2/PTM_RATIO); // bottom-left corner // Call the body factory which allocates memory for the ground body // from a pool and creates the ground box shape (also from a pool). // The body is also added to the world. b2Body* groundBody = world->CreateBody(&groundBodyDef); // Define the ground box shape. b2PolygonShape groundBox; // bottom groundBox.SetAsBox(screenSize.width/2/PTM_RATIO, 0, b2Vec2(0, -screenSize.height/2/PTM_RATIO), 0); groundBody->CreateFixture(&groundBox, 0); // top groundBox.SetAsBox(screenSize.width/2/PTM_RATIO, 0, b2Vec2(0, screenSize.height/2/PTM_RATIO), 0); groundBody->CreateFixture(&groundBox, 0); // left groundBox.SetAsBox(0, screenSize.height/2/PTM_RATIO, b2Vec2(-screenSize.width/2/PTM_RATIO, 0), 0); groundBody->CreateFixture(&groundBox, 0); // right groundBox.SetAsBox(0, screenSize.height/2/PTM_RATIO, b2Vec2(screenSize.width/2/PTM_RATIO, 0), 0); groundBody->CreateFixture(&groundBox, 0); //Set up sprite CCSpriteBatchNode *mgr = CCSpriteBatchNode::batchNodeWithFile(s_pPathBlock, 150); addChild(mgr, 0, kTagSpriteManager); addNewSpriteWithCoords( CCPointMake(screenSize.width/2, screenSize.height/2) ); CCLabelTTF *label = CCLabelTTF::labelWithString("Tap screen", "Marker Felt", 32); addChild(label, 0); label->setColor( ccc3(0,0,255) ); label->setPosition( CCPointMake( screenSize.width/2, screenSize.height-50) ); scheduleUpdate(); }
// on "init" you need to initialize your instance bool Sprite3DLesson5::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object auto closeItem = MenuItemImage::create( "CloseNormal.png", "CloseSelected.png", CC_CALLBACK_1(Sprite3DLesson5::menuCloseCallback, this)); closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 , origin.y + closeItem->getContentSize().height/2)); // create menu, it's an autorelease object auto menu = Menu::create(closeItem, NULL); menu->setPosition(Vec2::ZERO); this->addChild(menu, 1); auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DLesson5::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); ///////////////////////////// std::string filename = "res/Sprite3D/girl.c3b"; auto sprite = Sprite3D::create(filename); sprite->setPosition(visibleSize.width/2 + origin.x, visibleSize.height/3 + origin.y); addChild(sprite); auto animation = Animation3D::create(filename); auto animate = Animate3D::create(animation); sprite->runAction(RepeatForever::create(animate)); auto lfoot = Sprite::create("res/Sprite3D/circle.png"); auto rfoot = Sprite::create("res/Sprite3D/circle.png"); _lfoot = Sprite3D::create(); _lfoot->addChild(lfoot); _lfoot->setRotation3D(Vec3(90, 0, 0)); _rfoot = Sprite3D::create(); _rfoot->addChild(rfoot); _rfoot->setRotation3D(Vec3(90, 0, 0)); addChild(_lfoot); addChild(_rfoot); _lfoot->setScale(0.3f); _rfoot->setScale(0.3f); _lfoot->setVisible(false); _rfoot->setVisible(false); _sprite = sprite; ValueMap valuemap0; valuemap0["footname"] = Value("Bip001 R Toe0"); valuemap0["lfoot"] = Value(false); animate->setKeyFrameUserInfo(10, valuemap0); valuemap0["footname"] = Value("Bip001 L Toe0"); valuemap0["lfoot"] = Value(true); animate->setKeyFrameUserInfo(26, valuemap0); auto listener2 = EventListenerCustom::create(Animate3DDisplayedNotification, [&](EventCustom* event) { auto info = (Animate3D::Animate3DDisplayedEventInfo*)event->getUserData(); auto footname = info->userInfo->at("footname").asString(); bool lfoot = info->userInfo->at("lfoot").asBool(); auto mat = _sprite->getNodeToWorldTransform() * _sprite->getSkeleton()->getBoneByName(footname)->getWorldMat(); Sprite3D* foot = lfoot ? _lfoot : _rfoot; foot->setPosition3D(Vec3(mat.m[12], mat.m[13], mat.m[14])); foot->setVisible(true); cocos2d::log("frame %d", info->frame); }); Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(listener2, -1); scheduleUpdate(); return true; }
void LevelEditorInputManager::onEnter() { CCNode::onEnter(); scheduleUpdate(); }
bool Failed::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object auto closeItem = MenuItemImage::create( "CloseNormal.png", "CloseSelected.png", CC_CALLBACK_1(Failed::menuCloseCallback, this)); closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 , origin.y + closeItem->getContentSize().height/2)); // create menu, it's an autorelease object auto menu = Menu::create(closeItem, NULL); menu->setPosition(Vec2::ZERO); this->addChild(menu, 1); ///////////////////////////// // 3. add your codes below... // add a label shows "Hello World" // create and initialize a label auto label = LabelTTF::create("", "Arial", 24); // position the label on the center of the screen label->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - label->getContentSize().height)); // add the label as a child to this layer this->addChild(label, 1); // add "GamePlaying" splash screen" auto sprite = Sprite::create("failed.png"); // position the sprite on the center of the screen sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); // add the sprite as a child to this layer this->addChild(sprite, 0); //_camera = new ActionCamera; //_camera->startWithTarget(menu); auto dispacher = Director::getInstance()->getEventDispatcher(); auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = CC_CALLBACK_2(Failed::onTouchBegan,this); listener->onTouchMoved = CC_CALLBACK_2(Failed::onTouchMoved,this); dispacher->addEventListenerWithSceneGraphPriority(listener,this); Director::getInstance()->setProjection(Director::Projection::_2D); scheduleUpdate(); runAction( Repeat::create( Sequence::create( Place::create(Vec2(0,-8)), DelayTime::create(0.1f), Place::create(Vec2(0,0)), DelayTime::create(0.1f), nullptr), 3) ); return true; }
/////////////////////////BLOB LAYER bool BlobLayer::init() { if (!Layer::init()) return false; Entity::Game = this; setContentSize(Size(DESIGN_X, DESIGN_Y)); b2Vec2 gravity; gravity.Set(0.0f, -10.0f); world = new b2World(gravity); world->SetContinuousPhysics(true); world->SetContactListener(this); // Create edges around the entire screen // Define the ground body. b2BodyDef groundBodyDef; groundBodyDef.position.Set(0, 0); // bottom-left corner // Call the body factory which allocates memory for the ground body // from a pool and creates the ground box shape (also from a pool). // The body is also added to the world. auto _groundBody = world->CreateBody(&groundBodyDef); // Define the ground box shape. b2EdgeShape groundBox; // bottom groundBox.Set(b2Vec2(0, 0), b2Vec2(DESIGN_X / PTM_RATIO, 0)); _groundBody->CreateFixture(&groundBox, 0); // top //groundBox.Set(b2Vec2(0, DESIGN_Y / PTM_RATIO), b2Vec2(DESIGN_X / PTM_RATIO, DESIGN_Y / PTM_RATIO)); //_groundBody->CreateFixture(&groundBox, 0); // left groundBox.Set(b2Vec2(0, DESIGN_Y * 1.1f / PTM_RATIO), b2Vec2(0, 0)); _groundBody->CreateFixture(&groundBox, 0); // right groundBox.Set(b2Vec2(DESIGN_X / PTM_RATIO, 0), b2Vec2(DESIGN_X / PTM_RATIO, DESIGN_Y * 1.1f / PTM_RATIO)); _groundBody->CreateFixture(&groundBox, 0); state = GameStates::Playing; scheduleUpdate(); //schedule(schedule_selector(BlobLayer::generate), 2.3f); bigText = Label::createWithTTF("", NORMAL_TTF, 200.0f); bigText->setHorizontalAlignment(TextHAlignment::CENTER); bigText->setVerticalAlignment(TextVAlignment::CENTER); bigText->setPosition(CP(0.5f, 0.45f)); addChild(bigText, 10); auto touchListener = EventListenerTouchOneByOne::create(); touchListener->onTouchBegan = CC_CALLBACK_2(BlobLayer::onTouchBegan, this); touchListener->onTouchMoved = CC_CALLBACK_2(BlobLayer::onTouchMoved, this); touchListener->onTouchEnded = CC_CALLBACK_2(BlobLayer::onTouchEnded, this); touchListener->onTouchCancelled = CC_CALLBACK_2(BlobLayer::onTouchEnded, this); getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener, this); auto tilt = EventListenerAcceleration::create(CC_CALLBACK_2(BlobLayer::onAcceleration, this)); getEventDispatcher()->addEventListenerWithSceneGraphPriority(tilt, this); ambientForce = b2Vec2_zero; regenPeriod = 1.5f; minRegenPeriod = regenPeriod * 0.5f; regenTime = 0; lastObservedScore = BlobScene::LastScore; schedule(schedule_selector(BlobLayer::checkCombo), 1.5f); /* auto ringParticle = ParticleGalaxy::create(); ringParticle->setPositionType(ParticleSystem::PositionType::RELATIVE); ring->addChild(ringParticle);*/ return true; }
SelectStage::SelectStage() : _winSize(Director::getInstance()->getWinSize()) { // Sprite Sheet // SpriteFrameCache::getInstance()->addSpriteFramesWithFile(SELECT_STAGE_PLIST); // init screen // initScreen(); // motion streak // _motionStreak = MotionStreak::create(3.0, 1.0f, 50.0f, Color3B::YELLOW, "ball.png"); addChild(_motionStreak); // listen touches auto dispatcher = Director::getInstance()->getEventDispatcher(); auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = [] (const vector<Touch *> & touches, Event * event) {}; listener->onTouchesEnded = [] (const vector<Touch *> & touches, Event * event) {}; dispatcher->addEventListenerWithSceneGraphPriority(listener, this); setTouchesEnabled(true); // time // time_t cl; // time(&cl); // printf("%ld: %ld", cl, time(NULL)); time_t timeValue; struct tm * timeObject; time(&timeValue); timeObject = localtime(&timeValue); printf("%d年%d月%d日 %d:%d", timeObject->tm_year + 1900 , timeObject->tm_mon + 1 , timeObject->tm_mday, timeObject->tm_hour, timeObject->tm_min); // char hour[100] = {static_cast<char>(timeObject->tm_hour)}; // char min[100] = {static_cast<char>(timeObject->tm_min)}; char hour = static_cast<char>(timeObject->tm_hour); char min = static_cast<char>(timeObject->tm_min); CCLOG("%c:%c", hour,min); printf("%c:%c", hour,min); int iHour = timeObject->tm_hour; unsigned char cHour = 0; cHour = iHour; // auto * get_hour = LabelTTF::create(asctime(timeObject->tm_hour), "Hevetica-BoldOblique", 20); auto * time = LabelTTF::create(asctime(timeObject) , "Hevetica-BoldOblique", 20); // auto * get_hour = LabelTTF::create(hour, "Hevetica-BoldOblique", 20); // auto * get_time = LabelTTF::create(min, "Hevetica-BoldOblique", 20); // // get_hour->setPosition(Point(_winSize.width * 0.45f, _winSize.height * 0.9f)); // get_time->setPosition(Point(_winSize.width * 0.55f, _winSize.height * 0.9f)); // addChild(get_hour, kForeground, 1); // addChild(get_time, kForeground, 1); time->setPosition(Point(_winSize.width / 2, _winSize.height * 0.9f)); addChild(time, kForeground, 1); _motionStreak = MotionStreak::create(3.0, 1.0f,50.0f, Color3B::YELLOW, "ball.png"); addChild(_motionStreak, kForeground); // Update scheduleUpdate(); }
bool GameScene_Chipmunk::init() { if ( !Scene::init() ) { return false; } //画面サイズサイズを取得 auto window_size = Director::getInstance()->getWinSize(); //床 auto floor = Sprite::create(); floor->setPosition(window_size.width/2, 0); floor->setTextureRect(Rect(0,0,window_size.width,100)); floor->setColor(Color3B(255,255,255)); floor->setTag(spriteType::kFloor); _floor = floor->getSpriteFrame()->getRect(); auto left_wall = Sprite::create(); left_wall->setPosition(10, window_size.height/2); left_wall->setTextureRect(Rect(0,0,10,window_size.height*2)); left_wall->setColor(Color3B(255,255,255)); _leftwall = left_wall->getSpriteFrame()->getRect(); auto right_wall = Sprite::create(); right_wall->setPosition(window_size.width, window_size.height/2); right_wall->setTextureRect(Rect(0,0,10,window_size.height*2)); right_wall->setColor(Color3B(255,255,255)); _rightwall = right_wall->getSpriteFrame()->getRect(); _ceil = Rect(window_size.width/2, window_size.height - 200, window_size.width, 20); //wall->setRotation(10.0f); //反発係数と摩擦係数 auto material = PHYSICSBODY_MATERIAL_DEFAULT; material.restitution = 0.0f; material.friction = 1.0f; auto pWall = PhysicsBody::createBox(floor->getContentSize(), material); //重力干渉を受けるか pWall->setDynamic(false); //回転させるか pWall->setRotationEnable(false); pWall->setContactTestBitmask(true); floor->setPhysicsBody(pWall); addChild(floor); auto pright_wall = PhysicsBody::createBox(right_wall->getContentSize(), material); //重力干渉を受けるか pright_wall->setDynamic(false); //回転させるか pright_wall->setRotationEnable(false); right_wall->setPhysicsBody(pright_wall); addChild(right_wall); auto pleft_wall = PhysicsBody::createBox(left_wall->getContentSize(), material); //重力干渉を受けるか pleft_wall->setDynamic(false); //回転させるか pleft_wall->setRotationEnable(false); left_wall->setPhysicsBody(pleft_wall); addChild(left_wall); //event listener //イベントリスナー作成 auto listener = EventListenerTouchAllAtOnce::create(); //イベントを飲み込むかどうか //listener->setSwallowTouches(true); //タッチメソッド設定 listener->onTouchesBegan = CC_CALLBACK_2(GameScene_Chipmunk::onTouchesBegan, this); listener->onTouchesMoved = CC_CALLBACK_2(GameScene_Chipmunk::onTouchesMoved, this); listener->onTouchesEnded = CC_CALLBACK_2(GameScene_Chipmunk::onTouchesEnded, this); //this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this); //優先度100でディスパッチャーに登録 this->getEventDispatcher()->addEventListenerWithFixedPriority(listener, 100); //衝突検知 auto plistener = EventListenerPhysicsContact::create(); plistener->onContactBegin = CC_CALLBACK_1(GameScene_Chipmunk::onContactBegin, this); this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(plistener, this); auto plistenerend = EventListenerPhysicsContact::create(); plistenerend->onContactPostSolve = CC_CALLBACK_2(GameScene_Chipmunk::onContactPostSolve, this); this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(plistenerend, this); this->fillBoll(); scheduleUpdate(); return true; }
NS_CC_BEGIN CCTCPSocketHub::CCTCPSocketHub() { scheduleUpdate(); };
void InputDeviceAdapterMouse::updateInputDevices(void) { if(window!=0) { /* Set mouse device's transformation and device ray: */ Point lastMousePos=inputDevices[0]->getPosition(); window->updateMouseDevice(mousePos,inputDevices[0]); /* Calculate the mouse device's linear velocity: */ inputDevices[0]->setLinearVelocity((inputDevices[0]->getPosition()-lastMousePos)/Vrui::getFrameTime()); if(mouseLocked) { /* Move the mouse cursor back to the window center: */ int windowCenter[2]; window->getWindowCenterPos(windowCenter); if(mousePos[0]!=windowCenter[0]||mousePos[1]!=windowCenter[1]) { for(int i=0; i<2; ++i) mousePos[i]=windowCenter[i]; window->setCursorPos(mousePos[0],mousePos[1]); /* Reset the mouse device's ray and transformation to the locked values: */ inputDevices[0]->setDeviceRay(lockedRayDirection,lockedRayStart); inputDevices[0]->setTransformation(lockedTransformation); } } /* Set mouse device button states: */ for(int i=0; i<numButtonStates; ++i) inputDevices[0]->setButtonState(i,buttonStates[i]); /* Set mouse device valuator states: */ int numValuators=1<<numModifierKeys; for(int i=0; i<numValuators; ++i) { /* Convert the mouse wheel tick count into a valuator value (ugh): */ double mouseWheelValue=double(numMouseWheelTicks[i])/3.0; if(mouseWheelValue<-1.0) mouseWheelValue=-1.0; else if(mouseWheelValue>1.0) mouseWheelValue=1.0; inputDevices[0]->setValuator(i,mouseWheelValue); /* If there were mouse ticks, request another Vrui frame in a short while because there will be no "no mouse ticks" message: */ if(numMouseWheelTicks[i]!=0) scheduleUpdate(getApplicationTime()+0.1); numMouseWheelTicks[i]=0; } #if 0 inputDevices[0]->setValuator(numValuators+0,Scalar(2)*mousePos[0]/window->getVRScreen()->getWidth()-Scalar(1)); inputDevices[0]->setValuator(numValuators+1,Scalar(2)*mousePos[1]/window->getVRScreen()->getHeight()-Scalar(1)); inputDevices[0]->setValuator(numValuators+2,0.0); inputDevices[0]->setValuator(numValuators+3,0.0); #endif } if(!textEvents.empty()||!textControlEvents.empty()) { /* Process all accumulated text and text control events: */ std::vector<std::pair<int,GLMotif::TextEvent> >::iterator teIt=textEvents.begin(); int teOrd=teIt!=textEvents.end()?teIt->first:nextEventOrdinal; std::vector<std::pair<int,GLMotif::TextControlEvent> >::iterator tceIt=textControlEvents.begin(); int tceOrd=tceIt!=textControlEvents.end()?tceIt->first:nextEventOrdinal; while(teIt!=textEvents.end()||tceIt!=textControlEvents.end()) { /* Process the next event from either list: */ if(teOrd<tceOrd) { getWidgetManager()->text(teIt->second); ++teIt; teOrd=teIt!=textEvents.end()?teIt->first:nextEventOrdinal; } else { getWidgetManager()->textControl(tceIt->second); ++tceIt; tceOrd=tceIt!=textControlEvents.end()?tceIt->first:nextEventOrdinal; } } /* Clear the event lists: */ nextEventOrdinal=0; textEvents.clear(); textControlEvents.clear(); } }
void HelloWorld::startGame(){ scheduleUpdate(); schedule(schedule_selector(HelloWorld::addBar), 1); }
void TestScene::onEnterTransitionDidFinish() { //launching update method scheduleUpdate(); }
static void setCurrentScreen (BaseScreen *screen) { currentScreen = screen; scheduleUpdate("new screen selected"); announceCurrentScreen(); }
void GameLayer::updateStart(float dt){ scheduleUpdate(); }
void JoystickLayer::generateJoystick() { Rect joystickBaseDimensions(0, 0, 6.0f, 6.0f); Point joystickBasePosition(SCREEN_W * 0.21f, SCREEN_H * 0.2f); Sprite* bg = Sprite::createWithSpriteFrameName("background.png"); Sprite* thumb = Sprite::createWithSpriteFrameName("thumb.png"); bg->setScale(0.37f); thumb->setScale(0.45f); SneakyJoystickSkinnedBase* joystickBase = new SneakyJoystickSkinnedBase(); _base = joystickBase; joystickBase->init(); joystickBase->setPosition(joystickBasePosition); joystickBase->setBackgroundSprite(bg); joystickBase->setThumbSprite(thumb); _joystick = new SneakyJoystick(); _joystick->initWithRect(joystickBaseDimensions); _joystick->autorelease(); joystickBase->setJoystick(_joystick); joystickBase->setPosition(joystickBasePosition); Rect jumpButtonDimensions(0, 0, 64.0f, 64.0f); Point jumpButtonPosition; jumpButtonPosition = ccp(SCREEN_W * 0.8f, SCREEN_H * 0.2f); SneakyButtonSkinnedBase *jumpButtonBase = new SneakyButtonSkinnedBase(); jumpButtonBase->init(); jumpButtonBase->setPosition(jumpButtonPosition); Sprite* button1 = Sprite::createWithSpriteFrameName("jumpButton.png"); button1->setScale(0.6f); jumpButtonBase->setDefaultSprite(button1); jumpButtonBase->setActivatedSprite(button1); jumpButtonBase->setDisabledSprite(button1); jumpButtonBase->setPressSprite(button1); _jumpButton = new SneakyButton(); _jumpButton->initWithRect(jumpButtonDimensions); _jumpButton->autorelease(); jumpButtonBase->setButton(_jumpButton); jumpButtonBase->setPosition(jumpButtonPosition); _jumpButton->retain(); Rect attackButtonDimensions(0, 0, 64.0f, 64.0f); Point attackButtonPosition; attackButtonPosition = ccp(SCREEN_W * 0.93f, SCREEN_H * 0.3f); SneakyButtonSkinnedBase *attackButtonBase = new SneakyButtonSkinnedBase(); attackButtonBase->init(); attackButtonBase->setPosition(attackButtonPosition); Sprite* button2 = Sprite::createWithSpriteFrameName("attackButton.png"); button2->setScale(0.6f); attackButtonBase->setDefaultSprite(button2); attackButtonBase->setActivatedSprite(button2); attackButtonBase->setDisabledSprite(button2); attackButtonBase->setPressSprite(button2); _attackButton = new SneakyButton(); _attackButton->initWithRect(attackButtonDimensions); _attackButton->autorelease(); attackButtonBase->setButton(_attackButton); attackButtonBase->setPosition(attackButtonPosition); _attackButton->retain(); this->addChild(attackButtonBase); this->addChild(jumpButtonBase); this->addChild(joystickBase); scheduleUpdate(); this->setTouchEnabled(true); }
// on "init" you need to initialize your instance bool SceneLocalization::init() { ////////////////////////////// // 1. super init first if (!SceneBase::init()) { return false; } cocos2d::Size windowSize = Director::getInstance()->getWinSize(); #if defined(AK_ANDROID) || defined(AK_IOS) float descriptionPosX = windowSize.width * 0.50f; float descriptionPosY = windowSize.height * 0.90f; float selectButtonPosX = windowSize.height * 0.50f; #else float descriptionPosX = windowSize.width * 0.50f; float descriptionPosY = windowSize.height * 0.90f; float selectButtonPosX = windowSize.width * 0.15f; #endif // AK_ANDROID ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. { //addLabel("Localization Demos Menu", descriptionPosX, descriptionPosY, 30); int y = descriptionPosY; // Add button linking to the Say "Hello" { auto selectItem = MenuItemImage::create("PlayNormal.png", "PlayPush.png", CC_CALLBACK_1(SceneLocalization::onSayHello, this)); y -= selectItem->getContentSize().height; addItem(selectItem, selectButtonPosX, y, this); addLabelEx("Say \"Hello\"", selectItem->getPosition().x + selectItem->getContentSize().width, selectItem->getPosition().y, FONT_SIZE_MENU, this, CC_CALLBACK_1(SceneLocalization::onSayHello, this)); } // Add button linking to RTPC Demo (Car Engine) { auto selectItem = MenuItemImage::create("PlayNormal.png", "PlayPush.png", CC_CALLBACK_1(SceneLocalization::onLanguageChanged, this)); y -= selectItem->getContentSize().height; addItem(selectItem, selectButtonPosX, y, this); cocos2d::MenuItemLabel* pMenu = addLabelEx("Language:English(US)", selectItem->getPosition().x + selectItem->getContentSize().width, selectItem->getPosition().y, FONT_SIZE_MENU, this, CC_CALLBACK_1(SceneLocalization::onLanguageChanged, this)); m_language = (Label*)pMenu->getChildren().at(0); } } // Load the sound bank AkBankID bankID; // Not used if (AK::SoundEngine::LoadBank("Human.bnk", AK_DEFAULT_POOL_ID, bankID) != AK_Success) { SetErrorMessage("Human.bnk"); return false; } LOGAK("<SceneLocalization::init>3"); // Register the "Human" game object AK::SoundEngine::RegisterGameObj(GAME_OBJECT_HUMAN, "Human"); scheduleUpdate(); return true; }
void VGALiquidCrystal::display() { display_on = true; scheduleUpdate(); }
void SchedulerUpdateFromCustom::schedUpdate(float dt) { unschedule(schedule_selector(SchedulerUpdateFromCustom::schedUpdate)); scheduleUpdate(); schedule(schedule_selector(SchedulerUpdateFromCustom::stopUpdate), 2.0f); }
void VGALiquidCrystal::scrollDisplayRight(void) { shiftChars--; scheduleUpdate(); }
void TwoSchedulers::onEnter() { SchedulerTestLayer::onEnter(); auto s = Director::getInstance()->getWinSize(); // rotate and jump auto jump1 = JumpBy::create(4, Point(0,0), 100, 4); auto jump2 = jump1->reverse(); auto seq = Sequence::create(jump2, jump1, NULL); auto action = RepeatForever::create(seq); // // Center // auto grossini = Sprite::create("Images/grossini.png"); addChild(grossini); grossini->setPosition(Point(s.width/2,100)); grossini->runAction(action->clone()); auto defaultScheduler = Director::getInstance()->getScheduler(); // // Left: // // Create a new scheduler, and link it to the main scheduler sched1 = new Scheduler(); defaultScheduler->scheduleUpdate(sched1, 0, false); // Create a new ActionManager, and link it to the new scheudler actionManager1 = new ActionManager(); sched1->scheduleUpdate(actionManager1, 0, false); for( unsigned int i=0; i < 10; i++ ) { auto sprite = Sprite::create("Images/grossinis_sister1.png"); // IMPORTANT: Set the actionManager running any action sprite->setActionManager(actionManager1); addChild(sprite); sprite->setPosition(Point(30+15*i,100)); sprite->runAction(action->clone()); } // // Right: // // Create a new scheduler, and link it to the main scheduler sched2 = new Scheduler();; defaultScheduler->scheduleUpdate(sched2, 0, false); // Create a new ActionManager, and link it to the new scheudler actionManager2 = new ActionManager(); sched2->scheduleUpdate(actionManager2, 0, false); for( unsigned int i=0; i < 10; i++ ) { auto sprite = Sprite::create("Images/grossinis_sister2.png"); // IMPORTANT: Set the actionManager running any action sprite->setActionManager(actionManager2); addChild(sprite); sprite->setPosition(Point(s.width-30-15*i,100)); sprite->runAction(action->clone()); } sliderCtl1 = sliderCtl(); addChild(sliderCtl1); sliderCtl1->retain(); sliderCtl1->setPosition(Point(s.width / 4.0f, VisibleRect::top().y - 20)); sliderCtl2 = sliderCtl(); addChild(sliderCtl2); sliderCtl2->retain(); sliderCtl2->setPosition(Point(s.width / 4.0f*3.0f, VisibleRect::top().y-20)); }
bool CtestLayer::init(){ CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); CCSize winSize=CCDirector::sharedDirector()->getWinSize(); //enable touch setTouchEnabled( true ); //enable update scheduleUpdate(); //update eye pos updateEyePos(); //----------------------------- //root3d m_root3d=new Cc3dRoot(); m_root3d->autorelease(); m_root3d->init(); m_root3d->setNodeName("root3d"); this->addChild(m_root3d); //camera Cc3dCamera*camera=m_root3d->getCamera3D(); m_r=(winSize.height/2)/tanf(camera->getFovy()/2*M_PI/180); camera->setEyePos(cc3dv4(0, 0, m_r, 1)); camera->setCenter(cc3dv4(0, 0, 0, 1)); camera->setUp(cc3dv4(0, 1, 0, 0)); camera->setProjectionMode(ec3dPerspectiveMode); //lightSource Cc3dLightSource*lightSource=new Cc3dLightSource(); lightSource->autorelease(); lightSource->init(); m_root3d->addChild(lightSource); lightSource->setAmbient(cc3dv4(0.8, 0.8, 0.8, 1)); lightSource->setPosition3D(cc3dv4(600, 900, 1200, 1)); //program Cc3dProgram*program=c3dGetProgram_c3dClassicLighting(); //material Cc3dMaterial*material=new Cc3dMaterial(); material->autorelease(); material->init(); material->setSpecular(cc3dv4(0.5, 0.5, 0.5, 1)); material->setShininess(10); //texture CCTexture2D*tex_logo=CCTextureCache::sharedTextureCache()->addImage("logo.png"); CCTexture2D*tex_logo2=CCTextureCache::sharedTextureCache()->addImage("logo2.png"); //mesh Cc3dMesh*mesh_ball=c3dCreateBallMesh(100, 20, 10, cc3dv4(1, 0.5, 0, 1), cc3dv4(0, 1, 0, 1)); mesh_ball->setTexture(tex_logo2); mesh_ball->setMaterial(material); mesh_ball->setNodeName("mesh_ball"); Cc3dMesh*mesh_box=c3dCreateBoxMesh(100,cc3dv4(1, 0, 0, 1),cc3dv4(0, 1, 0, 1),cc3dv4(0, 0, 1, 1),cc3dv4(1, 1, 0, 1), cc3dv4(0, 0, 1, 1),cc3dv4(1, 1, 0, 1),cc3dv4(1, 0, 0, 1),cc3dv4(0, 1, 0, 1)); mesh_box->setTexture(tex_logo); mesh_box->setMaterial(material); mesh_box->setNodeName("mesh_box"); Cc3dMesh*mesh_cone=c3dCreateConeMesh(100, 270, 20, 10, true, cc3dv4(1, 0, 0, 1), cc3dv4(0, 1, 0, 1)); mesh_cone->setTexture(tex_logo); mesh_cone->setMaterial(material); mesh_cone->setNodeName("mesh_cone"); //actors const int actorCount=3; vector<Cc3dMesh*> meshList; meshList.push_back(mesh_box); meshList.push_back(mesh_cone); meshList.push_back(mesh_ball); vector<Cc3dVector4> posList; posList.push_back(cc3dv4(-250, 0, 0, 1)); posList.push_back(cc3dv4(0, -100, 0, 1)); posList.push_back(cc3dv4(250, 0, 0, 1)); for(int i=0;i<actorCount;i++){ Cc3dActor* actor3D=new Cc3dActor(); actor3D->autorelease(); actor3D->init(); actor3D->setPosition3D(posList[i]); actor3D->addMesh(meshList[i]); actor3D->setLightSource(lightSource); actor3D->setCamera3D(camera); actor3D->setPassUnifoCallback(passUnifoCallback_classicLighting); actor3D->setProgram(program); actor3D->setNodeName("actor3d"); m_root3d->addChild(actor3D,0); m_actor3dList.push_back(actor3D); } //submit actors for(int i=0;i<(int)m_actor3dList.size();i++){ Cc3dActor*actor3D=m_actor3dList[i]; actor3D->submit(GL_STATIC_DRAW); } //controlButton_swithProjMode { CCScale9Sprite* btnUp=CCScale9Sprite::create("button.png"); CCScale9Sprite* btnDn=CCScale9Sprite::create("button_dn.png"); CCLabelTTF*title=CCLabelTTF::create("proj mode", "Helvetica", 30); CCControlButton* controlButton=CCControlButton::create(title, btnUp); controlButton->setBackgroundSpriteForState(btnDn,CCControlStateHighlighted); controlButton->setPreferredSize(CCSize(180,80)); controlButton->setPosition(ccp(400,100)); controlButton->addTargetWithActionForControlEvents(this, (SEL_CCControlHandler)(&CtestLayer::switchProjModeCallBack), CCControlEventTouchDown); this->addChild(controlButton); m_controlButton_swithProjMode=controlButton; } //controlButton_transform { CCScale9Sprite* btnUp=CCScale9Sprite::create("button.png"); CCScale9Sprite* btnDn=CCScale9Sprite::create("button_dn.png"); CCLabelTTF*title=CCLabelTTF::create("transform", "Helvetica", 30); CCControlButton* controlButton=CCControlButton::create(title, btnUp); controlButton->setBackgroundSpriteForState(btnDn,CCControlStateHighlighted); controlButton->setPreferredSize(CCSize(180,80)); controlButton->setPosition(ccp(700,100)); controlButton->addTargetWithActionForControlEvents(this, (SEL_CCControlHandler)(&CtestLayer::transformCallBack), CCControlEventTouchDown); this->addChild(controlButton); m_controlButton_transform=controlButton; } //projection mode label m_pLabel=CCLabelTTF::create("proj mode: Perspective", "Arial", 35); m_pLabel->setPosition(ccp(origin.x + visibleSize.width*(3.0/4), origin.y + visibleSize.height - m_pLabel->getContentSize().height-100)); this->addChild(m_pLabel, 1); return true; }
void MainScene::onEnterTransitionDidFinish() { // Schedule Updates scheduleUpdate(); }
bool CtestLayer::init() { CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); CCSize winSize=CCDirector::sharedDirector()->getWinSize(); //enable touch setTouchEnabled( true ); //enable update scheduleUpdate(); //update eye pos updateEyePos(); //----------------------------- //root3d m_root3d=new Cc3dRoot(); m_root3d->autorelease(); m_root3d->init(); m_root3d->setNodeName("root3d"); this->addChild(m_root3d); //camera Cc3dCamera*camera=m_root3d->getCamera3D(); m_r=(winSize.height/2)/tanf(camera->getFovy()/2*M_PI/180); camera->setEyePos(cc3dv4(0, 0, m_r, 1)); camera->setCenter(cc3dv4(0, 0, 0, 1)); camera->setUp(cc3dv4(0, 1, 0, 0)); camera->setProjectionMode(ec3dPerspectiveMode); //lightSource Cc3dLightSource*lightSource=new Cc3dLightSource(); lightSource->autorelease(); lightSource->init(); m_root3d->addChild(lightSource); lightSource->setAmbient(cc3dv4(0.8, 0.8, 0.8, 1)); lightSource->setPosition3D(cc3dv4(600, 900, 1200, 1)); //program Cc3dProgram*program=c3dGetProgram_c3dClassicLighting(); //material Cc3dMaterial*material=new Cc3dMaterial(); material->autorelease(); material->init(); material->setSpecular(cc3dv4(0.5, 0.5, 0.5, 1)); material->setShininess(10); //texture CCTexture2D*tex=CCTextureCache::sharedTextureCache()->addImage("white_outline.png"); //actors float r=40; m_nRow=3; m_nCol=4; m_nDeep=2; m_actor3dMat3d.resize(m_nRow); for(int i=0; i<m_nRow; i++) { m_actor3dMat3d[i].resize(m_nCol); for(int j=0; j<m_nCol; j++) { m_actor3dMat3d[i][j].resize(m_nDeep); } } float xspan=m_nCol*2*r; float yspan=m_nRow*2*r; float zspan=m_nDeep*2*r; float xmin=-xspan/2; float ymin=-yspan/2; float zmin=-zspan/2; for(int i=0; i<m_nRow; i++) { for(int j=0; j<m_nCol; j++) { for(int k=0; k<m_nDeep; k++) { //mesh Cc3dMesh*mesh_box=c3dCreateBoxMesh(r,cc3dv4(1, 1, 1, 1),cc3dv4(1, 1, 1, 1),cc3dv4(1, 1, 1, 1),cc3dv4(1, 1, 1, 1), cc3dv4(1, 1, 1, 1),cc3dv4(1, 1, 1, 1),cc3dv4(1, 1, 1, 1),cc3dv4(1, 1, 1, 1)); mesh_box->setTexture(tex); mesh_box->setMaterial(material); mesh_box->setNodeName("mesh_box"); //actor Cc3dActor* actor3D=new Cc3dActor(); actor3D->autorelease(); actor3D->init(); float x=xmin+r+j*2*r; float y=ymin+r+(m_nRow-1-i)*2*r; float z=zmin+r+(m_nDeep-1-k)*2*r; actor3D->setPosition3D(cc3dv4(x, y, z, 1)); actor3D->addMesh(mesh_box); actor3D->setLightSource(lightSource); actor3D->setCamera3D(camera); actor3D->setPassUnifoCallback(passUnifoCallback_classicLighting); actor3D->setProgram(program); actor3D->setNodeName("actor3d"); m_root3d->addChild(actor3D,0); m_actor3dMat3d[i][j][k]=actor3D; } } } //submit actors for(int i=0; i<m_nRow; i++) { for(int j=0; j<m_nCol; j++) { for(int k=0; k<m_nDeep; k++) { Cc3dActor*actor3D=m_actor3dMat3d[i][j][k]; actor3D->submit(GL_STATIC_DRAW); } } } //controlButton_swithProjMode { CCScale9Sprite* btnUp=CCScale9Sprite::create("button.png"); CCScale9Sprite* btnDn=CCScale9Sprite::create("button_dn.png"); CCLabelTTF*title=CCLabelTTF::create("clear", "Helvetica", 30); CCControlButton* controlButton=CCControlButton::create(title, btnUp); controlButton->setBackgroundSpriteForState(btnDn,CCControlStateHighlighted); controlButton->setPreferredSize(CCSize(180,80)); controlButton->setPosition(ccp(400,100)); controlButton->addTargetWithActionForControlEvents(this, (SEL_CCControlHandler)(&CtestLayer::clearCallBack), CCControlEventTouchDown); this->addChild(controlButton); m_controlButton_clear=controlButton; } //projection mode label m_pLabel=CCLabelTTF::create("proj mode: Perspective", "Arial", 35); m_pLabel->setPosition(ccp(origin.x + visibleSize.width*(3.0/4), origin.y + visibleSize.height - m_pLabel->getContentSize().height-100)); this->addChild(m_pLabel, 1); return true; }
void QWmpPlayerControl::positionChangeEvent(double , double) { scheduleUpdate(PositionChanged); }