当前位置:  编程技术>移动开发
本页文章导读:
    ▪利用闹钟定时实施逻辑-转载        利用闹钟定时执行逻辑--转载 Intent intent = new Intent(TFNoticeTicketReceiver.ACTION_NOTICE); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent,0); Calendar calendar = Calendar.getInstance();   AlarmManager alarmMan.........
    ▪ coco2d-x 2.0学习系列(2):CCNode        coco2d-x 2.0学习系列(二):CCNode CCNode是一个核心的类,直接继承至CCObject,CCObject类是cocos2d-x中所有对象的基类,它封装了对象的引用计数和自动释放功能。CCNode是场景、层、菜单、精灵等所有.........
    ▪ coco2d-x 2.0学习系列(2):CCScene       coco2d-x 2.0学习系列(二):CCScene 场景(CCScene)   函数:bool init () 初始化函数   static CCScene* create(void ) 创建场景函数 场景切换效果: CCDirector::sharedDirector()->replaceScene(scene));//默认场景的切.........

[1]利用闹钟定时实施逻辑-转载
    来源: 互联网  发布时间: 2014-02-18
利用闹钟定时执行逻辑--转载

Intent intent = new Intent(TFNoticeTicketReceiver.ACTION_NOTICE);

PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent,0);

Calendar calendar = Calendar.getInstance();

 

AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);  

        alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);  

        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 10*1000, pendingIntent);

 

 

  • //取消闹钟按钮事件监听  
  •         final Button cancelAlarmBtn = (Button)findViewById(R.id.cancelAlarmBtn);  
  •         cancelAlarmBtn.setOnClickListener(new Button.OnClickListener(){  
  •             @Override  
  •             public void onClick(View arg0) {  
  •                 Intent intent = new Intent(Alarm.this,AlarmReceiver.class);  
  •                 PendingIntent pendingIntent = PendingIntent.getBroadcast(Alarm.this, 0, intent, 0);  
  •                 //获取闹钟管理器  
  •                 AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);  
  •                 alarmManager.cancel(pendingIntent);  
  •                 Toast.makeText(Alarm.this, "闹钟已经取消!", Toast.LENGTH_SHORT).show();  
  •             }  
  •         }); 

  •     
    [2] coco2d-x 2.0学习系列(2):CCNode
        来源: 互联网  发布时间: 2014-02-18
    coco2d-x 2.0学习系列(二):CCNode
    CCNode是一个核心的类,直接继承至CCObject,CCObject类是cocos2d-x中所有对象的基类,它封装了对象的引用计数和自动释放功能。CCNode是场景、层、菜单、精灵等所有节点的父类。
    
    
    CCNode是cocos2d-x的渲染链,cocos2d-x同时只能渲染一个scene,因此scene是渲染的根节点,一般树的渲染顺序是scene添加n个CCLayer,一个CCLayer添加n个CCSprite或者CCMenu,CCSprite还可以添加CCParticleSystem,这样就构建了一个渲染树,cocos2d-x历遍这个树来将图像显示在屏幕上。
    coco2d-x->visit() 调用Child的zOrder<0的visit()函数,然后调用draw()函数。再调用Child的zOrder>=0的visit()函数。(深度优先的算法 zOrder大的显示在最上层)。
    主要函数:
    Public Member Functions
    virtual CCCamera * 	getCamera ()
     获取节点相机 
    virtual bool 	isRunning ()
    virtual void 	cleanup (void)
     	停止节点所有运行的 actions 和schedulers. 
     
    virtual void 	draw (void)
    绘制自己
    virtual void 	visit (void)
    访问节点 
    CCRect 	boundingBox (void)
     	Returns a "local" axis aligned bounding box of the node. 
     
    Setters & Getters for Graphic Peroperties
    virtual void 	setZOrder (int zOrder)
    设置节点顺序,值越大显示越靠前
    virtual void 	_setZOrder (int z)
     	Sets the z order which stands for the drawing order. 
     
    virtual int 	getZOrder ()
     	获取节点顺序
     
    virtual void 	setVertexZ (float vertexZ)
     	Sets the real OpenGL Z vertex. 
     
    virtual float 	getVertexZ ()
     	Gets OpenGL Z vertex of this node. 
     
    virtual void 	setScaleX (float fScaleX)
     	Changes the scale factor on X axis of this node. 
     
    virtual float 	getScaleX ()
     	Returns the scale factor on X axis of this node. 
     
    virtual void 	setScaleY (float fScaleY)
     	Changes the scale factor on Y axis of this node. 
     
    virtual float 	getScaleY ()
     	Returns the scale factor on Y axis of this node. 
     
    virtual void 	setScale (float scale)
     	Changes both X and Y scale factor of the node. 
     
    virtual float 	getScale ()
     	Gets the scale factor of the node, when X and Y have the same scale factor. 
     
    virtual void 	setPosition (const CCPoint &position)
     设置节点位置 
    virtual const CCPoint & 	getPosition ()
     	获取节点位置
     
    void 	setPosition (float x, float y)
     	Sets position in a more efficient way. 
     
    void 	getPosition (float *x, float *y)
     	Gets position in a more efficient way, returns two number instead of a CCPoint object. 
     
    void 	setPositionX (float x)
     	Gets/Sets x or y coordinate individually for position. 
     
    float 	getPositionX (void)
     
    void 	setPositionY (float y)
     
    float 	getPositionY (void)
     
    virtual void 	setSkewX (float fSkewX)
     	Changes the X skew angle of the node in degrees. 
     
    virtual float 	getSkewX ()
     	Returns the X skew angle of the node in degrees. 
     
    virtual void 	setSkewY (float fSkewY)
     	Changes the Y skew angle of the node in degrees. 
     
    virtual float 	getSkewY ()
     	Returns the Y skew angle of the node in degrees. 
     
    virtual void 	setAnchorPoint (const CCPoint &anchorPoint)
     	Sets the anchor point in percent. 
     
    virtual const CCPoint & 	getAnchorPoint ()
     	//获取节点的锚点的位置
     
    virtual const CCPoint & 	getAnchorPointInPoints ()
     	Returns the anchorPoint in absolute pixels. 
     
    virtual void 	setContentSize (const CCSize &contentSize)
     	Sets the untransformed size of the node. 
     
    virtual const CCSize & 	getContentSize ()
     	Returns the untransformed size of the node. 
     
    virtual void 	setVisible (bool visible)
     	Sets whether the node is visible. 
     
    virtual bool 	isVisible ()
     	Determines if the node is visible. 
     
    virtual void 	setRotation (float fRotation)
     	Sets the rotation (angle) of the node in degrees. 
     
    virtual float 	getRotation ()
     	Returns the rotation of the node in degrees. 
     
    virtual void 	setRotationX (float fRotaionX)
     	Sets the X rotation (angle) of the node in degrees which performs a horizontal rotational skew. 
     
    virtual float 	getRotationX ()
     	Gets the X rotation (angle) of the node in degrees which performs a horizontal rotation skew. 
     
    virtual void 	setRotationY (float fRotationY)
     	Sets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew. 
     
    virtual float 	getRotationY ()
     	Gets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew. 
     
    virtual void 	setOrderOfArrival (unsigned int uOrderOfArrival)
     	Sets the arrival order when this node has a same ZOrder with other children. 
     
    virtual unsigned int 	getOrderOfArrival ()
     	Returns the arrival order, indecates which children is added previously. 
     
    virtual void 	setGLServerState (ccGLServerState glServerState)
     	Sets the state of OpenGL server side. 
     
    virtual ccGLServerState 	getGLServerState ()
     	Returns the state of OpenGL server side. 
     
    virtual void 	ignoreAnchorPointForPosition (bool ignore)
     	Sets whether the anchor point will be (0,0) when you position this node. 
     
    virtual bool 	isIgnoreAnchorPointForPosition ()
     	Gets whether the anchor point will be (0,0) when you position this node. 
     
    Children and Parent
    virtual void 	addChild (CCNode *child)
     	Adds a child to the container with z-order as 0. 
     
    virtual void 	addChild (CCNode *child, int zOrder)
     	Adds a child to the container with a z-order. 
     
    virtual void 	addChild (CCNode *child, int zOrder, int tag)
     	Adds a child to the container with z order and tag. 
     
    CCNode * 	getChildByTag (int tag)
     	Gets a child from the container with its tag. 
     
    virtual CCArray * 	getChildren ()
     	Return an array of children. 
     
    unsigned int 	getChildrenCount (void)
     	Get the amount of children. 
     
    virtual void 	setParent (CCNode *parent)
     	Sets the parent node. 
     
    virtual CCNode * 	getParent ()
     	Returns a pointer to the parent node. 
     
    virtual void 	removeFromParent ()
     	Removes this node itself from its parent node with a cleanup. 
     
    virtual void 	removeFromParentAndCleanup (bool cleanup)
     	Removes this node itself from its parent node. 
     
    virtual void 	removeChild (CCNode *child)
     	Removes a child from the container with a cleanup. 
     
    virtual void 	removeChild (CCNode *child, bool cleanup)
     	Removes a child from the container. 
     
    virtual void 	removeChildByTag (int tag)
     	Removes a child from the container by tag value with a cleanup. 
     
    virtual void 	removeChildByTag (int tag, bool cleanup)
     	Removes a child from the container by tag value. 
     
    virtual void 	removeAllChildren ()
     	Removes all children from the container with a cleanup. 
     
    virtual void 	removeAllChildrenWithCleanup (bool cleanup)
     	Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. 
     
    virtual void 	reorderChild (CCNode *child, int zOrder)
     	Reorders a child according to a new z value. 
     
    virtual void 	sortAllChildren ()
     	Sorts the children array once before drawing, instead of every time when a child is added or reordered. 
     
    Grid object for effects
    virtual CCGridBase * 	getGrid ()
     	Returns a grid object that is used when applying effects. 
     
    virtual void 	setGrid (CCGridBase *pGrid)
     	Changes a grid object that is used when applying effects. 
     
    Tag & User data
    virtual int 	getTag ()
     	Returns a tag that is used to identify the node easily. 
     
    virtual void 	setTag (int nTag)
     	Changes the tag that is used to identify the node easily. 
     
    virtual void * 	getUserData ()
     	Returns a custom user data pointer. 
     
    virtual void 	setUserData (void *pUserData)
     	Sets a custom user data pointer. 
     
    virtual CCObject * 	getUserObject ()
     	Returns a user assigned CCObject. 
     
    virtual void 	setUserObject (CCObject *pUserObject)
     	Returns a user assigned CCObject. 
     
    Shader Program
    virtual CCGLProgram * 	getShaderProgram ()
     	Return the shader program currently used for this node. 
     
    virtual void 	setShaderProgram (CCGLProgram *pShaderProgram)
     	Sets the shader program for this node. 
     
    Script Bindings for lua
    virtual void 	registerScriptHandler (int handler)
     	Registers a script function that will be called in onEnter() & onExit() seires functions. 
     
    virtual void 	unregisterScriptHandler (void)
     	Unregisters a script function that will be called in onEnter() & onExit() series functions. 
     
    int 	getScriptHandler ()
     	Gets script handler for onEnter/onExit event. 
     
    void 	scheduleUpdateWithPriorityLua (int nHandler, int priority)
     	Schedules for lua script. 

     


        
    [3] coco2d-x 2.0学习系列(2):CCScene
        来源: 互联网  发布时间: 2014-02-18
    coco2d-x 2.0学习系列(二):CCScene

    场景(CCScene)

     

    函数:bool init () 初始化函数

     

    static CCScene* create(void )

    创建场景函数

    场景切换效果:

    CCDirector::sharedDirector()->replaceScene(scene));//默认场景的切换

    //场景切换添加效果

    CCDirector::sharedDirector()->replaceScene(CCTransitionJumpZoom::transitionWithDuration(1.2f,gameOverScene));

    //总结的场景切换效果

    CCTransitionJumpZoom::transitionWithDuration(t, s);//跳跃式,本场景先会缩小,然后跳跃进来

    CCTransitionFade::transitionWithDuration(t, s);//淡出淡入,原场景淡出,新场景淡入

    CCTransitionFade::transitionWithDuration(t, s, ccWHITE);//如果上一个的函数,带3个参数,则第三个参数就是淡出淡入的颜色

    CCTransitionFlipX::transitionWithDuration(t, s, kOrientationLeftOver);//x轴左翻

    CCTransitionFlipX::transitionWithDuration(t, s, kOrientationRightOver);//x轴右翻

    CCTransitionFlipY::transitionWithDuration(t, s, kOrientationUpOver);//y轴上翻

    CCTransitionFlipY::transitionWithDuration(t, s, kOrientationDownOver);//y轴下翻

    CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver);//有角度转的左翻

    CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationRightOver);//有角度转的右翻

    CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationLeftOver);//带缩放效果x轴左翻

    CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationRightOver);//带缩放效果x轴右翻

    CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationUpOver);//带缩放效果y轴上翻

    CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationDownOver);//带缩放效果y轴下翻 

    CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver);//带缩放效果/有角度转的左翻

    CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationRightOver);//带缩放效果有角度转的右翻

    CCTransitionShrinkGrow::transitionWithDuration(t, s);//交错换

    CCTransitionRotoZoom::transitionWithDuration(t, s);//转角换

    CCTransitionMoveInL::transitionWithDuration(t, s);//新场景从左移入覆盖

    CCTransitionMoveInR::transitionWithDuration(t, s);//新场景从右移入覆盖

    CCTransitionMoveInT::transitionWithDuration(t, s);//新场景从上移入覆盖

    CCTransitionMoveInB::transitionWithDuration(t, s);//新场景从下移入覆盖

    CCTransitionSlideInL::transitionWithDuration(t, s);//场景从左移入推出原场景

    CCTransitionSlideInR::transitionWithDuration(t, s);//场景从右移入推出原场景

    CCTransitionSlideInT::transitionWithDuration(t, s);//场景从上移入推出原场景

    CCTransitionSlideInB::transitionWithDuration(t, s);//场景从下移入推出原场景

    以下三个需要检测opengl版本是否支持CCConfiguration::sharedConfiguration()->getGlesVersion() <= GLES_VER_1_0如果为真则为不支持

    CCTransitionCrossFade::transitionWithDuration(t,s);//淡出淡入交叉,同时进行

    CCTransitionRadialCCW::transitionWithDuration(t,s);//顺时针切入

    CCTransitionRadialCW::transitionWithDuration(t,s);//逆时针切入

    以下两个需要先设置摄像机,使用CCDirector::sharedDirector()->setDepthTest(true);

    CCTransitionPageTurn::transitionWithDuration(t, s, false);//翻页,前翻

    CCTransitionPageTurn::transitionWithDuration(t, s, true);//翻页,后翻

    CCTransitionFadeTR::transitionWithDuration(t, s);//向右上波浪

    CCTransitionFadeBL::transitionWithDuration(t, s);//向左下波浪

    CCTransitionFadeUp::transitionWithDuration(t, s);//向上百叶窗

    CCTransitionFadeDown::transitionWithDuration(t, s);//向下百叶窗

    CCTransitionTurnOffTiles::transitionWithDuration(t, s);//随机小方块

    CCTransitionSplitRows::transitionWithDuration(t, s);//按行切

    CCTransitionSplitCols::transitionWithDuration(t, s);//按列切

     

     

     


        
    最新技术文章:
    ▪Android开发之登录验证实例教程
    ▪Android开发之注册登录方法示例
    ▪Android获取手机SIM卡运营商信息的方法
    ▪Android实现将已发送的短信写入短信数据库的...
    ▪Android发送短信功能代码
    ▪Android根据电话号码获得联系人头像实例代码
    ▪Android中GPS定位的用法实例
    ▪Android实现退出时关闭所有Activity的方法
    ▪Android实现文件的分割和组装
    ▪Android录音应用实例教程
    ▪Android双击返回键退出程序的实现方法
    ▪Android实现侦听电池状态显示、电量及充电动...
    ▪Android获取当前已连接的wifi信号强度的方法
    ▪Android实现动态显示或隐藏密码输入框的内容
    ▪根据USER-AGENT判断手机类型并跳转到相应的app...
    ▪Android Touch事件分发过程详解
    ▪Android中实现为TextView添加多个可点击的文本
    ▪Android程序设计之AIDL实例详解
    ▪Android显式启动与隐式启动Activity的区别介绍
    ▪Android按钮单击事件的四种常用写法总结
    ▪Android消息处理机制Looper和Handler详解
    ▪Android实现Back功能代码片段总结
    ▪Android实用的代码片段 常用代码总结
    ▪Android实现弹出键盘的方法
    ▪Android中通过view方式获取当前Activity的屏幕截...
    ▪Android提高之自定义Menu(TabMenu)实现方法
    ▪Android提高之多方向抽屉实现方法
    ▪Android提高之MediaPlayer播放网络音频的实现方法...
    ▪Android提高之MediaPlayer播放网络视频的实现方法...
    ▪Android提高之手游转电视游戏的模拟操控
     


    站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3