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

  • Home
  • SEARCH
  • 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 4270468
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:18:37+00:00 2026-05-21T07:18:37+00:00

Im generating a plain txt file from Physics editor. It contains all the vertices

  • 0

Im generating a plain txt file from Physics editor. It contains all the vertices for my polygon. Because I want my polygon to be textured, im running it through a triangulation method located at: https://github.com/asinesio/cocos2d-PRKit/
And I need my data to come from an NSMutableArray to doso for it to work.

Physics editor can export .plist and .txt files, but for simplicity sake, I just want to get the vertices from the .txt file and turn them into CGPoints and then add them into a NSMutableArray

The txt file looks like this:

(53.4011993408203, -44.4011993408203)
, (74.4011993408203,
-38.4011993408203) , (-0.598802387714386,
0.598802387714386) , (-0.598802387714386,
-39.4011993408203) , …

I think the method would be to:
Load the data from its source.
Scan the data excluding parenthesis and alphbetical characters.
Take all the data upto the comma and add it into the CGPoint (x(1),y(0)).
Then scan all the data upto the next comma and insert it into the CGPoint (x(1),y(1)).
Then add this CGPoint to a NSMutableArray.
Continue scanning the document until all coordinates have been added.

This method could then be used with different text-files to create simplicity. Etc:
Level1ground.txt, Level2ground.txt.. It would be fantastic if I could get it running.

Could someone please help me with this?
Much Appreciated,
Oliver.

  • 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-21T07:18:38+00:00Added an answer on May 21, 2026 at 7:18 am

    This solution assumes that you have loded the file already into a string.
    You can make use of pathForResource:ofType:inDirectory: of NSBundle class to load a file.

    NSArray * rawPoints = [@"(53.4011993408203, -44.4011993408203) , (74.4011993408203, -38.4011993408203) , (-0.598802387714386, 0.598802387714386) , (-0.598802387714386, -39.4011993408203)" componentsSeparatedByString:@" , "];
    for (NSString * rawPoint in rawPoints) {
        NSString *tmp = [rawPoint stringByReplacingOccurrencesOfString:@"(" withString:@""];
        tmp = [tmp stringByReplacingOccurrencesOfString:@"(" withString:@""];
    
        NSArray * coordinates = [tmp componentsSeparatedByString:@", "];
    
        CGPoint point;
        for (NSString * coordinate in coordinates) {
            point = CGPointMake([[coordinates objectAtIndex:0] floatValue],
                                [[coordinates objectAtIndex:1] floatValue]);
        }
        NSLog(@"x:%f, y:%f", point.x, point.y);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XSLT file generating plain HTML. I need to wrap some elements
I'm failing in generating a test executable file containing all my google tests with
I'm generating some xml files that needs to conform to an xsd file that
I'm currently generating SQL insert statements from more than one tables, and in the
I'm generating plain simple links with CakePHP's HtmlHelper the following way: $html->link(Newest, array( 'controller'
we're currently generating all our official documents using XSL-FO transformation using .xml files as
i am generating *.reg file using code which will have some important data. and
I'm generating the csv file with the following header commands: header(Content-type: text/csv; charset=utf-8; encoding=utf-8);
For generating PDF from HTML, i need to fill a variable with output from
IWAB0398E Error in generating WSDL from Java: java.lang.ClassCastException: org.apache.axis.encoding.ser.BeanSerializer cannot be cast to org.apache.axis.encoding.Serializer

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.