Cocos2d-2.x_CCControlPotentiometer旋钮控件

Cocos2d-2.x_CCControlPotentiometer旋钮控件,第1张

概述#ifndef __HELLO_WORLD_H__#define __HELLO_WORLD_H__#include "cocos2d.h"#include "cocos-ext.h"USING_NS_CC;USING_NS_CC_EXT;class HelloWorld : public cocos2d::CCLayer {public: HelloWorld();
#ifndef __HELLO_WORLD_H__#define __HELLO_WORLD_H__#include "cocos2d.h"#include "cocos-ext.h"USING_NS_CC;USING_NS_CC_EXT;class HelloWorld : public cocos2d::cclayer {public:	HelloWorld();    virtual ~HelloWorld();        static cocos2d::CCScene* scene();	virtual bool init();	voID valueChanged(CCObject * pSender,CCControlEvent controlEvent);	CREATE_FUNC(HelloWorld);};#endif
#include "HelloWorldScene.h"#include "SimpleAudioEngine.h"HelloWorld::HelloWorld(){}HelloWorld::~HelloWorld(){}CCScene* HelloWorld::scene(){	CCScene *scene = CCScene::create();	HelloWorld *layer = HelloWorld::create();	scene->addChild(layer);	return scene;}bool HelloWorld::init(){	if (!cclayer::init())	{		return false;	}	//CCControlPotentiometer参数是底座,进度条,控制按钮图片资源	CCControlPotentiometer * potentiometer = CCControlPotentiometer::create("crop1.png","crop2.png","crop2.png");	//设置最大值和最小值以及初值	potentiometer->setMaximumValue(100.0);	potentiometer->setMinimumValue(0.0);	potentiometer->setValue(50);	potentiometer->setposition(ccp(240,160));	this->addChild(potentiometer);	//添加事件监听	potentiometer->addTargetWithActionForControlEvents(this,cccontrol_selector(HelloWorld::valueChanged),CCControlEventValueChanged);	return true;}voID HelloWorld::valueChanged(CCObject * pSender,CCControlEvent controlEvent){	CCControlPotentiometer * potentiometer = (CCControlPotentiometer *)pSender;	CCString * string = CCString::createWithFormat("%f",potentiometer->getValue());	cclog(string->getCString());}
总结

以上是内存溢出为你收集整理的Cocos2d-2.x_CCControlPotentiometer旋钮控件全部内容,希望文章能够帮你解决Cocos2d-2.x_CCControlPotentiometer旋钮控件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1056853.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存