Skip to content

Instantly share code, notes, and snippets.

@Muratam
Last active September 30, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Muratam/5c1c601c286997d0a08e to your computer and use it in GitHub Desktop.
Save Muratam/5c1c601c286997d0a08e to your computer and use it in GitHub Desktop.
cocosのui::Button で一つの画像を使って透過で押すのと押さないのを判断させるコード
//#include "ui/CocosGUI.h"
auto button = ui::Button::create(ButtonFileName, "");
button->addTouchEventListener([button](Ref* pSender, cocos2d::ui::Widget::TouchEventType type){
switch (type){
case ui::Widget::TouchEventType::BEGAN:
//Write Process
button->setOpacity(255);
break;
case ui::Widget::TouchEventType::ENDED:
case ui::Widget::TouchEventType::CANCELED:
//Write Process
button->setOpacity(100);
break;
}
});
button->setOpacity(100);
this->addchild(button);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment