CUiScene.h
void sliderMove(Ref* ref, ui::Slider::EventType type);
void sliderTouch(Ref* ref, ui::Widget::TouchEventType type);
CUiScene.cpp
void CUiScene::sliderMove(Ref * ref, ui::Slider::EventType type)
{
if (type == ui::Slider::EventType::ON_PERCENTAGE_CHANGED) {
auto obj = this->getChildByName("dice");
auto slider = (ui::Slider*)ref;
float Slider_Percentage = slider->getPercent();
//obj->setScale(Slider_Percentage / 20);
obj->setPositionX(Slider_Percentage*10);
if (AudioEngine::getState(sound_index) == AudioEngine::AudioState::PLAYING) {
experimental::AudioEngine::setVolume(sound_index, Slider_Percentage);
}
auto load = (ui::LoadingBar*)this->getChildByName("BgBar")->getChildByName("LD");
load->setPercent(Slider_Percentage);
}
}
void CUiScene::sliderTouch(Ref * ref, ui::Widget::TouchEventType type)
{
if (type == ui::Widget::TouchEventType::ENDED) {
auto slider = (ui::Slider*)ref;
float Slider_Percentage = slider->getPercent();
if (Slider_Percentage <= 12.5f) {
slider->setPercent(0);
}
else if (Slider_Percentage > 12.5f && Slider_Percentage<=37.5f) {
slider->setPercent(25);
}
else if (Slider_Percentage > 37.5f && Slider_Percentage <= 62.5f) {
slider->setPercent(50);
}
else if (Slider_Percentage > 62.5 && Slider_Percentage <= 87.5f) {
slider->setPercent(75);
}
else {
slider->setPercent(100);
}
}
}
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos/audio/include)
LOCAL_MODULE := MyGame_shared
LOCAL_MODULE_FILENAME := libMyGame
LOCAL_SRC_FILES := $(LOCAL_PATH)/hellocpp/main.cpp \
$(LOCAL_PATH)/../../../Classes/AppDelegate.cpp \
$(LOCAL_PATH)/../../../Classes/HelloWorldScene.cpp\
$(LOCAL_PATH)/../../../proj.win32/CUiScene.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes
# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END
LOCAL_STATIC_LIBRARIES := cocos2dx_static
# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END
include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)
# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END
if i using ui functions, and build for android, build is fail
because of not added front of ui, cocos2d::
if i change all ui:;~ to cocos2d::ui::~, problem is solved.
but I want only using ui::~
in VS2017, I using USING_NS_CC, so I didn’t write cocos2d:;~
but android build has problem.
how can I fix this problem?