I am using cocos2dx3.7.1.Now i want to get postion on mouse moved.For that i use ccTouchMoved method but actyaly this method is not compile.so how can i move sprite on mouse move??My code is:

  • amisha
    Likes 0

    Problem Description

    void HelloWorld::onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event)

    {
        sprite->setPosition(touch->getLocation())

    ;CCLOG("onTouchmoved x = %f, y = %f", touch->getLocation().x, touch->getLocation().y);
      CCLOG("You moved  Here");  
    }

  • Sonar Systems admin
    Likes 0

    Code doesn’t compile?


    This reply has been verified.
  • amisha
    Likes 0

    I am using cocos2dx3.7.1.Now i want to get postion on mouse moved.For that i use ccTouchMoved method but actyaly this method is not compile.so how can i move sprite on mouse move??My code is:

    void HelloWorld::onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event)

    {
        sprite->setPosition(touch->getLocation());

    CCLOG("onTouchmoved x = %f, y = %f", touch->getLocation().x, touch->getLocation().y);
      CCLOG("You moved  Here");  
    }


  • Sonar Systems admin
    Likes 0

    Have you watched our tutorial?


    This reply has been verified.
  • amisha
    Likes 0

    yes….its solve now.

  • Sonar Systems admin
    Likes 0

    SWEET 


    This reply has been verified.
  • amisha
    Likes 0

    sir now i want to implement scrollview .In that for scrolling ietm take as a button.so if i want to take multipal button in one for loop then how can i do???

     for ( int i = 0; i < 8 i++ )
        {
            ui::Button *button = ui::Button::create( "menu1.png", "menu1.png" );
            button->setPosition( Vec2( scrollView->getContentSize( ).width /2, i * 70 ) );
            scrollView->addChild( button,50 );
        }


    This code is for only 1 ietm is repeat  7 time but i want to diffrent 7 ietm in one time in scrollview .

    And in scrollview 

    scrollView->setContentSize( Size( 2000, 200 ) );
        scrollView->setInnerContainerSize( Size( 1280, 2500 ) );

    how can it calculate for diffrent scrollview ????And what is the use of this 2 line for scrollview??

     


  • Sonar Systems admin
    Likes 0

    How different will each button be?


    This reply has been verified.
  • amisha
    Likes 0

    its diffrent image means menu1.png,menu2.png,menu3.png etc

  • Sonar Systems admin
    Likes 1

    use cocos2d::__String to create the button name with a variable.

  • amisha
    Likes 0

    ok sir thank you

  • Sonar Systems admin
    Likes 0

    Your welcome :D

  • Sonar Systems admin
    Likes 1

    Have you seen our Cocos Helper (https://github.com/SonarSystems/Cocos-Helper)

  • amisha
    Likes 0

    yes sir

    I also refer  your video tutorial.

  • amisha
    Likes 0

    sir now i want get touch of the sprite.How can i get the touch of the sprite in onTouchBegan(Touch* touch, Event* event)  this method.Now i implement the code in

    bool Level_Screen::onTouchBegan(Touch* touch, Event* event)
    {
        CCLOG("onTouchBegan x = %f, y = %f", touch->getLocation().x, touch->getLocation().y);
        
        CCLOG("You Touched Here");
       
           if(level1->boundingBox().containsPoint(location))
        {
            level_change=1;
            Scene *scene = HelloWorld::createScene( );
            Director::getInstance( )->replaceScene(TransitionProgressRadialCW::create(0.5,scene));
        }

    }

    But here problem is that  i am not getting the touch smothely.I tap multipal time on sprite then transition occure.

     

     

  • Sonar Systems admin
    Likes 0

  • amisha
    Likes 0

    I using the settag() for identify the each item in MenuIetmImag.I call the method on ietm touch.But how can i get the tag on specific item.

    void HelloWorld::selectSprite(Ref *sender)
    {
      
    }

    In this method what i should write for get the tag.

    I write for getting the tag   int tag=sender->getReferenceCount();

    but it’s not proper working.

     

  • Sonar Systems admin
    Likes 1

    You need to cast the sender like so

     

    MenuItemImage *menuItem = static_cast<MenuItemImage *>( sender );

     

    Now you should be able to use the menuItem normally


    This reply has been verified.
  • amisha
    Likes 0

    sorry sir..

    i am not getting

    Where is the write above line and how the use of menuietm


  • Sonar Systems admin
    Likes 1

    void HelloWorld::selectSprite(Ref *sender)
    {
    MenuItemImage *menuItem = static_cast<MenuItemImage *>( sender );
    
    int tag=menuItem->getTag();
    }

     

  • amisha
    Likes 0

    Thanks a lot sir


    This reply has been verified.
  • amisha
    Likes 0

    In scrollview ,all the item is move when i scroll any where on the screen.but if i want to scroll within some specific width then how can i do ??


    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    What is the specific width?


    This reply has been verified.
  • amisha
    Likes 0

    i want to keep that around 300.

  • Sonar Systems admin
    Likes 1

    Check this out for more information on UI http://cocos.sonarlearning.co.uk/docs/ui-elements-such-as-uibutton


    This reply has been verified.
  • amisha
    Likes 0

    I take screen shot in a game. Now i want to share on facebook then how can i share a screenshot???

    And i implement the code for screenshot  and sharing that is from also sonarsystem,

    SonarCocosHelper::IOS::Share("My game iMage","screnshot.png");

     

  • Sonar Systems admin
    Likes 0

    Have you got it working in a sprite.

  • amisha
    Likes 0

    yes sir..any static image is share but screenshot image is not share.My code is.

    void HelloWorld::afterCaptured(bool succeed, const std::string& outputFile)
    {
        if (succeed) {
        
            auto sp = Sprite::create(outputFile);
            this->addChild(sp, 255, "fg");
            Size s = Director::getInstance()->getWinSize();
            sp->setPosition(s.width / 2, s.height / 2);
            sp->setScale(0.25);
            SonarCocosHelper::IOS::Share("My post game","screnshot.png");
            
        }
        else
        {
            log("Capture screen failed.");
        }
    }

     

    utils::captureScreen( CC_CALLBACK_2(HelloWorld::afterCaptured, this), “screnshot.png" );

     


  • Sonar Systems admin
    Likes 0

    use sp for the image to share.

  • amisha
    Likes 0

    i use sp like this

    SonarCocosHelper::IOS::Share("My post game","sp”);

    but still image doesn’t share.

    Exactly how  and where is write?

  • Sonar Systems admin
    Likes 0

    try that

     

    SonarCocosHelper::IOS::Share("My post game",sp->getCString());

  • amisha
    Likes 0

    I try this but  stil image not show

  • Sonar Systems admin
    Likes 0

    Try a local image from resources.

  • amisha
    Likes 0

    ya ..its show but screen shot not show..

    error occure like no member named getCsrtring in cocos2d::sprite


  • Sonar Systems admin
    Likes 0

    try .getCString()


    This reply has been verified.
  • amisha
    Likes 0

    if i try sp.getcstring then again give the error  like fix it  replace “.”  with “ ->”.then i fix it error occure  “ no member named getCsrtring in cocos2d::sprite”

  • amisha
    Likes 0

    its done


  • amisha
    Likes 0

    when i tap multipal time on sharing button then half screen show blak not full screenshot visible….how can i solve this issue.

    error in logcat:

    ImageIO: CGImageReadGetBytesAtOffset : *** ERROR *** CGImageSource was created with data size: 4425741 - current size is only: 4417265
    2015-08-21 16:11:41.150 DressMeUp-mobile[1677:221559] plugin com.apple.share.Facebook.post invalidated

     


  • Sonar Systems admin
    Likes 0

    Could you post this as a separate question please.

Login to reply