Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6785299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:06:36+00:00 2026-05-26T17:06:36+00:00

pls any one help me i have create the edges in my project.i know

  • 0

pls any one help me

i have create the edges in my project.i know how to check touch position is inside the shape

if (fix->TestPoint(locationWorld))
    {
        CCLOG(@"****touch inside shape***");
    }

but i want create hexagon shape and i need to ball create inside hexagon shape and move inside hexagon.

i did ball move inside hexagon shape using below code:
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0, 0);
b2Body* groundBody = world->CreateBody(&groundBodyDef);

int countVal=[pos count];
// Define the ground box shape.
b2PolygonShape groundBox;
int range=[pos count]-2;

CCLOG(@"countVal=%d,range=%d",countVal,range);

for (int i=0; i<=range; i=i+2)
{
    float x1,y1,x2,y2;

    x1=[[pos objectAtIndex:i] floatValue];
    y1=[[pos objectAtIndex:i+1] floatValue];

    if (i==range)
    {
        x2=[[pos objectAtIndex:0] floatValue];
        y2=[[pos objectAtIndex:1] floatValue];

    }
    else 
    {
        x2=[[pos objectAtIndex:i+2] floatValue];
        y2=[[pos objectAtIndex:i+3] floatValue];

    }

            CCLOG(@"x1=%f,y1=%f,x2=%f,y2=%f",x1,y1,x2,y2);

    groundBox.SetAsEdge(b2Vec2(x1/PTM_RATIO,y1/PTM_RATIO),b2Vec2(x2/PTM_RATIO,y2/PTM_RATIO));
    groundBody->CreateFixture(&groundBox, 0);

}

but i dont know how to find touch position is inside polygon shape.i use cocos2d with box2d

pls any one help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:06:36+00:00Added an answer on May 26, 2026 at 5:06 pm

    Finally i got the answer:
    i am checking if the point is inside polygon:

    int pnpoly(int npol, float *xp, float *yp, float x, float y)
    {
      int i, j, c = 0;
      for (i = 0, j = npol-1; i < npol; j = i++) 
    {
        if ((((yp[i] <= y) && (y < yp[j])) ||
             ((yp[j] <= y) && (y < yp[i]))) &&
            (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
          c = !c;
      }
      return c;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any one help me? i have the xml with 2 steps. example : <listgroup
I am trying to create a slider like this example. pls anyone help me.
pls help me how to create a .htaccess file as index.php?regional=aaa domain.com/aaa/ list.php?regional=aaa&ctg=bbb&orderby=ccc&page=123 domain.com/list/aaa/bbb/ccc/123/
I have a doubt about windows message queue, and message loop. Could any one
hey can any one help me to go to next activity via next click
Pls check code .html form gets submitted even if javascript returns false. <form id=form1
I want to create a XML file in csharp like the below format pls
I have a question that can I use AS400ConnectionPool in Spring if then pls
i dont have any experience in python programming but I get to run python
I have created one SMSapplication and i need to test it on my android

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.