I'm trying to modify a sublime text textmate-style tmPreference file to have an additional setting. Initially the file has symbol list setting that applies just to the scope of headlines:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Symbol List</string>
<key>scope</key>
<string>text.orgmode orgmode.headline</string>
<key>settings</key>
<dict>
<key>showInSymbolList</key>
<integer>1</integer>
</dict>
</dict>
</plist>
But I want to add in a comment mechanism that applies to any line in the file:
<key>scope</key>
<string>source.orgmode</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>; </string>
</dict>
</array>
</dict>
Is there a way to handle multiple scopes within a single tmPreferences file?
It's easier just to have make two .tmPreference files instead. Sublime Text will scan your plugin's folder for the multiple tmPreference files.
I'm trying to modify an existing language definition that defines comments like this:
<dict>
<key>match</key>
<string>(#) .*$\n?</string>
<key>name</key>
<string>comment.line.number-sign.myLanguage</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.myLanguage</string>
</dict>
</dict>
</dict>
This ensures that a line starting with a # will be identified as a comment and highlighted accordingly. What I would like to do is surround a commented word in asterisks and have it show up as some other thing, a keyword for example. But simply appending this doesn't work:
<dict>
<key>match</key>
<string>\*([^*]+)\*</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.myLanguage</string>
</dict>
</dict>
</dict>
However, it does work if the line doesn't start with a #, so I'm assuming there is a conflict between both rules. So, I thought I could get around it by using a regex that identifies everything in the comment that isn't surrounded by *, something like:
# This is a comment *this is something else* this is still a comment *not* yes
Any ideas?
Ok, I got it to work:
<dict>
<key>begin</key>
<string>(#) .*</string>
<key>name</key>
<string>comment.line.number-sign.myLanguage</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.myLanguage</string>
</dict>
<key>0</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>keyword.myLanguage</string>
<key>match</key>
<string>\*[^*]+\*</string>
</dict>
</array>
</dict>
</dict>
<key>end</key>
<string>$\n?</string>
I'm using the PhysicsEditor tool to export a compound shape for box2d. I've second-checked everything I can think of - but the collision shapes are coming out several times larger than the sprite shape.
The ptm_ratio values are correct, the class that loads these GB2ShapeCache is applying the ptm_ratio properly to the vertex coords, I've made the anchorpoint is set to the middle, just like cocos2d.
No matter what the ptm ratio is, the bounding box is usually several times larger than the sprite. As if the sprite size was multiplied by 5. I've tried this for two different sprites and I see the same result.
Any ideas?
<key>asteroid-small</key>
<dict>
<key>anchorpoint</key>
<string>{ 0.5000,0.5000 }</string>
<key>fixtures</key>
<array>
<dict>
<key>density</key> <real>10</real>
<key>friction</key> <real>0.1</real>
<key>restitution</key> <real>0.1</real>
<key>filter_categoryBits</key> <integer>1</integer>
<key>filter_groupIndex</key> <integer>0</integer>
<key>filter_maskBits</key> <integer>65535</integer>
<key>isSensor</key> <false/>
<key>id</key> <string></string>
<key>fixture_type</key> <string>POLYGON</string>
<key>polygons</key>
<array>
<array>
<string>{ -13.000,10.500 }</string>
<string>{ -14.000,5.500 }</string>
<string>{ -13.000,-6.500 }</string>
<string>{ 7.000,-13.500 }</string>
<string>{ 16.000,-5.500 }</string>
<string>{ 16.000,2.500 }</string>
<string>{ 10.000,13.500 }</string>
<string>{ -3.000,12.500 }</string>
</array>
<array>
<string>{ -8.000,-17.500 }</string>
<string>{ -2.000,-17.500 }</string>
<string>{ 7.000,-13.500 }</string>
<string>{ -13.000,-6.500 }</string>
<string>{ -13.000,-12.500 }</string>
</array>
<array>
<string>{ 1.000,17.500 }</string>
<string>{ -3.000,12.500 }</string>
<string>{ 10.000,13.500 }</string>
<string>{ 5.000,17.500 }</string>
</array>
<array>
<string>{ -13.000,-6.500 }</string>
<string>{ -14.000,5.500 }</string>
<string>{ -16.000,3.500 }</string>
<string>{ -16.000,-1.500 }</string>
</array>
</array>
</dict>
I'm working with templates for a Backbone app that are stored in the HTML in <script type="text/template"> elements, but this is becoming frustrating because Sublime Text colors the HTML within a template as though it were Javascript. I'd like to get the editor to consider these script tags the same as normal HTML tags.
I've tried modifying the regexes in the source.js.embedded.html block on HTML.tmLanguage, but as somebody who's inexperienced with regular expressions, I can't get it right.
Any ideas?
This is, I believe, the relevant part of the tmLanguage file that needs to be modified:
<key>begin</key>
<string>(?<!</(?:script|SCRIPT))(>)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.tag.html</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>entity.name.tag.script.html</string>
</dict>
</dict>
<key>end</key>
<string>(</)((?i:script))</string>
I think you should edit the other value:
<key>begin</key>
<string>(?:^\s+)?(<)((?i:script))\b(?![^>]*/>)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.tag.html</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>entity.name.tag.script.html</string>
</dict>
</dict>
and replace (?:^\s+)?(<)((?i:script))\b(?![^>]*/>)
with (?:^\s+)?(<)((?i:script))\b(?![^>]*/>)(?![^>]*type="text/template")
I am developing for iPad with Cocos2D 2.0.
I have these lines:
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:#"atlas.plist"];
CCSpriteBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:#"atlas.png"];
[self addChild:batchNode];
CCSprite *mySprite = [CCSprite spriteWithFrameName:#"white.png"];
it fails miserably with this error:
Cocos2d: CCSpriteFrameCache: Frame 'white.png' not found
* Assertion failure in -[CCSprite initWithSpriteFrame:], /Users/myUser/Documents/MyApp/MyApp/libs/cocos2d/CCSprite.m:212**
I have generated the plist using TexturePacker. TexturePacker created 4 files: atlas-ipadhd.plis, atlas-ipadhd.png, atlas.plist and atlas.png.
white-ipadhd.png is a 2x2 white picture. white.png is a 1x1 white picture.
This is the content of atlas-ipadhd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>frames</key>
<dict>
<key>white-ipadhd.png</key>
<dict>
<key>frame</key>
<string>{{162,2},{2,2}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{2,2}}</string>
<key>sourceSize</key>
<string>{2,2}</string>
</dict>
<key>bgNormal-ipadhd.png</key>
<dict>
<key>frame</key>
<string>{{2,2},{348,78}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{348,78}}</string>
<key>sourceSize</key>
<string>{348,78}</string>
</dict>
<key>bgPressed-ipadhd.png</key>
<dict>
<key>frame</key>
<string>{{82,2},{348,78}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{348,78}}</string>
<key>sourceSize</key>
<string>{348,78}</string>
</dict>
</dict>
<key>metadata</key>
<dict>
<key>format</key>
<integer>2</integer>
<key>realTextureFileName</key>
<string>atlas-ipadhd.png</string>
<key>size</key>
<string>{256,512}</string>
<key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:f709325b7d140d102cd10dd90ef475b0$</string>
<key>textureFileName</key>
<string>atlas-ipadhd.png</string>
</dict>
</dict>
</plist>
This is atlas.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>frames</key>
<dict>
<key>white.png</key>
<dict>
<key>frame</key>
<string>{{84,2},{1,1}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{1,1}}</string>
<key>sourceSize</key>
<string>{1,1}</string>
</dict>
<key>bgNormal.png</key>
<dict>
<key>frame</key>
<string>{{2,2},{174,39}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{174,39}}</string>
<key>sourceSize</key>
<string>{174,39}</string>
</dict>
<key>bgPressed.png</key>
<dict>
<key>frame</key>
<string>{{43,2},{174,39}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{174,39}}</string>
<key>sourceSize</key>
<string>{174,39}</string>
</dict>
</dict>
<key>metadata</key>
<dict>
<key>format</key>
<integer>2</integer>
<key>realTextureFileName</key>
<string>atlas.png</string>
<key>size</key>
<string>{128,256}</string>
<key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:c3c8dd4637d116b049a6b55c8ad175d0$</string>
<key>textureFileName</key>
<string>atlas.png</string>
</dict>
</dict>
</plist>
this is atlas-ipadhd.png and atlas.png
after looking at this for hours, I cannot able to find anything wrong with these files... but it still crashes catastrophically.
any clues? thanks.
the sprite frame name should be white.png in atlas-ipadhd.plist.
straight from the horses' mouth:
+(id)spriteWithSpriteFrameName:(NSString*)spriteFrameName
{
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:spriteFrameName];
NSAssert1(frame!=nil, #"Invalid spriteFrameName: %#", spriteFrameName);
return [self spriteWithSpriteFrame:frame];
}
There is no attempt to correct the frame name with device specific keys. This way your code can remain completely device agnostic, you just have to provide the resources (textures and plists) with the appropriate device specific file names.