267 auto ret = VibrateTestDemo::init();
270 std::string fontFilePath =
"fonts/arial.ttf";
272 auto& layerSize = this->getContentSize();
274 auto vibrateItem = TextButton::create(
"vibrate", [&](TextButton* button){
277 vibrateItem->setPosition(layerSize.width * 0.5f, layerSize.height * 0.7f);
278 addChild(vibrateItem);
280 auto durationLabelValue = StringUtils::format(
"duration: %.3fs",
_duration);
282 auto durationLabel = Label::createWithTTF(durationLabelValue, fontFilePath, 20);
283 durationLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
284 durationLabel->setPosition(layerSize.width * 0.5f, layerSize.height * 0.5f);
285 addChild(durationLabel);
288 auto durationSlider = SliderEx::create();
289 durationSlider->setPercent(0);
290 durationSlider->setCallBack([&](SliderEx* sender,
float ratio, SliderEx::TouchEvent event){
292 auto durationLabelValue = StringUtils::format(
"duration: %.3fs",
_duration);
293 (
static_cast<Label*
>(
_durationLabel))->setString(durationLabelValue);
295 durationSlider->setPosition(Vec2(layerSize.width * 0.5f, layerSize.height * 0.35f));
296 addChild(durationSlider);