zoukankan      html  css  js  c++  java
  • sprite 根据相对弧度旋转

    void MainLayer::ccTouchesEnded(CCSet *pTouches, CCEvent*pEvent)
    
    {
    
       CCSize size=CCDirector::sharedDirector()->getWinSize();
    
        CCSetIterator it = pTouches->begin();
    
        CCTouch* touch = (CCTouch*)(*it);
    
           CCPoint location = touch->getLocation();
    
        CCNode* s = getChildByTag(kTagSprite);
    
        s->stopAllActions();
    
        s->runAction( CCMoveTo::create(1, ccp(location.x, location.y) ) );
    
        CCLog("xx===%f,yy===%f",location.x, location.y);
    
        CCLog("w===%f,h===%f",size.width, size.height);
    
        float o = location.x - s->getPosition().x;
    
        float a = location.y - s->getPosition().y;
    
         CCLog("w===%f,h===%f",a, o);
    
        float at = (float) CC_RADIANS_TO_DEGREES( atanf( o/a) );
    
        CCLog("%f",at);
    
    //    CCLog("%f",fabs(at));
    
        if( a < 0 )
    
        {
    
            if(  o < 0 )
    
                at = 180 + fabs(at);
    
            else
    
                at = 180 - fabs(at);    
    
        }
    
        s->runAction( CCRotateTo::create(1, at) );
    
    }
  • 相关阅读:
    frame、center和bounds
    UILabel
    UIColor
    Url_Filter(Code)
    listView介绍
    C# 常用正则
    C++指针的概念
    指针所具有的四个要素:
    windows_sendEmail
    工作笔记
  • 原文地址:https://www.cnblogs.com/jiackyan/p/3019909.html
Copyright © 2011-2022 走看看