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 9260655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:56:55+00:00 2026-06-18T12:56:55+00:00

I have a Cocos2D tmx file which is very much like an xml and

  • 0

I have a Cocos2D tmx file which is very much like an xml and includes carriage returns and spaces.

My requirements are:

In every tmx file in Resources/maps_sideScrolling/

find and everything between

<tileset firstgid="1"

and the first occurring

<layer name="background"

and replace with the contents of Resources/maps_sideScrolling/tileProperties.txt

I’ve tried the following with no result. The problem is caused by the string to be searched has multiple lines.

sed -i '' 's{<tileset firstgid="1.*<layer name="background"{Resources/maps_sideScrolling/tileProperties.txt{g' Resources/maps_sideScrolling/*.tmx;

Here’s a pastebin of the tmx snippet that I want to edit: http://pastebin.com/wr39zj1r

  • 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-06-18T12:56:56+00:00Added an answer on June 18, 2026 at 12:56 pm

    Geek uses python to do this kind of thing to TMX map files. Just an option to consider.

    Something like this (but iterating all files in directory etc), and save it as a .sh file:

    #!/usr/bin/env python
    
    import re
    
    #you'd open a file and read in the tile properties thing
    fakeTileProperties = "<tileproperties>1</tileproperties>\r"
    
    f = open( "file1.tmx", "rU")
    fo = open( "outputfile.tmx", "wc");
    
    #read source file
    s = f.read();
    
    #find what you need
    m = re.search("([\W\w]*)(<tileset firstgid=\"1\"[\W\w]*)(<layer name=\"background\"[\W\w]*)", s )
    
    #write out to source file
    fo.write(m.group(1))
    fo.write(fakeTileProperties)
    fo.write(m.group(3));
    
    f.close();
    fo.close();
    
    print "done!"
    

    The code handles content before the tile set firstgid=”1″ just in case there is some.

    To use a script like this in Xcode 4 do the following:

    • put your script in a file next to your project file, name it myscript.py
    • use chmod +x myscript.py to make the script file executable.
    • in your Xcode project select the project and target and “Build Phases” tab and then create a new “Run Script” build phase.
    • leave the default shell of /bin/sh
    • put the following into the script field: $(SOURCE_ROOT)/myscript.py

    Then when you do a build you should see the python script get executed. You can do a really simple test python file to test this (I just did):

    #!/usr/bin/env python
    
    print 'hello from python!'
    

    note that the setting in the Run Script setup “Show Environmental variables in build log” is very helpful for getting the environmental variables like SOURCE_ROOT and such to locate your files.

    good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In cocos2D I currently have a very simple particle emitter initialized like this: turnEmitter
Ok, so my project (which does have Cocos2d) has 3 UITableViews. So far, I
What I would like to do is have the Cocos2d shared director to replace
I am using cocos2d and have the following code which moves my layer based
I have a usual iOS Cocos2d game. I start with a MainMenuViewController, which then
I have game application (cocos2d) in which, a ball is to be shooted from
I have a cocos2d hierarchy of layers that is very very deep. I want
I have cocos2d class which produces memory leak if I do not release autoreleased
In Xcode/cocos2d/box2d I have methods in an .m file called Level1.m, and another in
I have a cocos2d game setup which uses basic inheritance setup which is similar

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.