Fork me on GitHub

Updates from britg RSS Toggle Comment Threads | Keyboard Shortcuts

  • britg 6:13 pm on August 29, 2011 Permalink | Log in to leave a Comment
    Tags: , ,   

    Working with the Myriad Coordinate Systems Available in Cocos2d 

    Lately, I find myself spending more of my free time working on a little game using Cocos2d. One of the things I was surprised to discover is that there’s not just a single coordinate system — there are four (that I know of — please correct me if I’m wrong).

    The four I know of:

    • Core Graphics space
    • Open GL space
    • Node space
    • Node space relative to anchor point

    I wasn’t totally clear on these going in, and I regret it. I ended up writing a lot of code that mish-mashed these and had to refactor it all.

    Most likely you’re going to be processing a touch input on an iOS device and translating that to a coordinate system inside of a Cocos2d node (most likely a CCLayer) as such:


    UITouch *touch = [touches anyObject];
    CGPoint point = [touch locationInView: [touch view]];
    CGPoint glPoint = [[CCDirector sharedDirector] convertToGL:point];
    CGPoint nodePoint = [self convertTouchToNodeSpace:touch];
    CGPoint nodePointAR = [self convertTouchToNodeSpaceAR:touch];

    With that in mind, here’s how I understand them:

    Core Graphics (point) — This is what you normally work in if you’re accustomed to iOS development with UIKit and similar APIs. CGPoint(0, 0) is in the top left corner of the screen and ascending Y values go down towards the bottom of the screen.

    Open GL (glPoint) — This coordinate system has (0, 0) in the bottom left of the screen, and ascending Y values go up towards the top of the screen.

    Node space (nodePoint) — This space is relative to the origin of the reference node with which you are observing the point, and follows the same rules as the Open GL system. If your node is full-screen and unshifted (e.g. a default CCLayer), this coordinate system is exactly the same as the Open GL system.

    Node space relative to anchor point (nodePointAR) — In Cocos2d, the default anchor point of any node is its center point. This coordinate system is relative to that center point. If you redefine the anchor point, this system is adjusted.

    The big gotcha that I ran into was that I was doing something frowned upon in Cocos2d: shifting Layers! I was then using the Node space throughout my code but expecting points to resolve to Open GL space. So, word to wise: understand these coordinate systems going in, and don’t shift the position of your Layers!

     
    • Web design London 7:42 pm on December 29, 2011 Permalink

      Cocos2D has an inverted coordinate system to what you’re used to – the … Now before we can see this running, we first need to tell Cocos2D to run our …..the entire game scene, more information is available in this thread.

    • Lulubysg 9:05 am on March 1, 2012 Permalink

       Many thanks regarding an additional helpful site.

    • Anonymous 9:06 am on March 1, 2012 Permalink

       Its like you examine my thoughts! You appear to understand so a lot about this, like you wrote the book in it or anything.

  • britg 3:58 pm on August 27, 2011 Permalink | Log in to leave a Comment
    Tags: , personal   

    Chew Your Own Adventure 

    I’m afraid to even say it for fear that 28 years of bad habits and ignorance backed by generations of genes might rear their ugly heads, but recently I’ve had a modicum of success with living and eating healthier. Analyzing this, the “why” and the “how” become clear. Why: my dad had a heart attack recently — that’s scary! How: well, by obsessing about food.

    *Queue plot twist music*

    I’m not quite sure how to explain it, but by making food a thing it’s easier for me to respect and indulge in it. Understanding something leads to the ability to discern and appreciate quality and creativity.

    So, to facilitate this I’ve started a Tumblr: Chew Your Own Adventure. This’ll keep all my food and cooking exploits in one tidy location. Be sure to check it out if you have an interest!

     
  • britg 8:21 pm on August 24, 2011 Permalink | Log in to leave a Comment
    Tags:   

    Cantelo- No You Di’int! 

    I’ve moved my food postings to a new location: Chew Your Own Adventure.

    After trying this amazing Peach and Basil Salad a few weeks ago, I’ve been enamored with this fruit-plus-basil salad concept. To me, it’s the perfect summer salad: served cold with sweet and tangy flavors.

    This time though I was looking for more of a side-dish than a salad, and this episode of Good Eats wherein Alton Brown does some great stuff with melons came to mind… particularly the part where he grills a musk melon in a wok.

    Combine that with some bacon (or Prosciutto if you want to get fancy) and you got yourself a killer summer side-dish.

    Musk Melon, it’s your time to shine!

    Ingredients:

    • 1/2 Musk Melon
    • 2 slices of cooked and chopped bacon
    • 5 leaves fresh basil
    • 1 handful of dried cranberries
    • 1 oz goat cheese, crumbled
    • 1 tablespoon balsamic vinegar
    • pinch of salt to taste

    Cut the musk melon into half-inch cubes, and coarsely chop the basil leaves. Combine all the ingredients together and refrigerate for about 30 minutes.

    This really has it all: tangy, fruity, savory, herby, and cheesy flavors all mix for a great side that compliments chicken (as I did below), fish or anything really. Enjoy!

     
  • britg 7:12 pm on August 18, 2011 Permalink | Log in to leave a Comment
    Tags:   

    So, You’ve Ordered a Pizza and Eaten It… 

    I’ve moved my food postings to a new location: Chew Your Own Adventure.

    … and now you have dozens of left over parmesan and red paper flake packets. You know the ones I’m talking about. What ever to do with them?

    Here’s what: Kale chips. Start with this simple recipe and just before you put it in the oven, take those left over packets and sprinkle them over the kale to your hearts content.


    The spiciness of the red pepper flakes, and the texture of the pizza-grade parmesan complement the greeny flavor of the kale and go really well with a cheesy sandwich like a panini, or a even with a burger. Enjoy!

     
  • britg 8:13 pm on August 4, 2011 Permalink | Log in to leave a Comment
    Tags:   

    Garlic Bok Choy with Carrots 

    I’ve moved my food postings to a new location: Chew Your Own Adventure.

    From a few different sources I’ve culled together a simple, tasty and healthy side dish: Garlic Bok Choy with Carrots.

    Ingredients

    • 2 heads of Bok Choy
    • 3 large carrots
    • 2 – 3 cloves garlic

    This one couldn’t be simpler: heat a tablespoon of olive oil in a wok on medium-high. Cut the carrots diagonally into chips and cook for about 5 minutes, or until the carrots start to lighten in color around the edges.

    While the carrots are cooking, finely dice 2-3 cloves of garlic. Chop the the Bok Choy into thirds, rinse and drain.

    Add the garlic to the carrots, stirring for no more than a minute. Drop in the Bok Choy and cook for another couple of minutes. Dig deep into the wok with a wooden spoon to get the garlic off the bottom of the wok and onto the leafy greens. This’ll prevent it from burning and mix everything up.

    Cook the Bok Choy until it starts to wilt then remove from heat. Voila! Simple, tasty, and healthy.

     
  • britg 6:32 pm on August 3, 2011 Permalink | Log in to leave a Comment
    Tags: , newrelic   

    New Relic Menu Bars: Now With More Options 

    A small update to New Relic Menu Bars has been approved and is live on the app store. Update away!

    What’s new? There were some requests for an icon-only option, so to accommodate that there’s now a “metric’ selector” (see below). Want just the icon? Deselect all the metrics, and bam you’ve got an icon-only New Relic menu bar.

    Oh, and I’ve also added an option to start the menu bar on startup. It defaults to off.

    Also, clicking on the menu bar item will display your metrics in the menu now regardless of which you have displayed in the bar.

    Enjoy! Click here to get New Relic Menu Bars through the App Store.

     
  • britg 10:25 am on July 24, 2011 Permalink | Log in to leave a Comment
    Tags:   

    From the Department of Things You Can Cream Braise: Turnips 

    I’ve moved my food postings to a new location: Chew Your Own Adventure.

    Continuing my infatuation with cream braising, I wanted to try something that would pair well with a good steak.

    First thought: potatoes. Nah, the steak was going to be rich and adding creamy potatoes would have taken the meal over the top. Fortunately, I’d already found a suitably lighter alternative with turnips and other tubers. So, it’s your turn turnips; braise in that cream!

    Ingredients (serves 2)

    • One large fresh turnip
    • One cup half and half (for a lighter cream)

    Dice the turnip into bite-size chunks, and sauté in olive oil for about 5 minutes seasoning them with salt and pepper to taste. Add the half and half, cover, reduce the heat to low and let simmer for about 45 minutes.

    Overall, the turnips made a great alternative to potatoes — highly recommended!

     
    • web design bangalore 1:49 pm on August 4, 2011 Permalink

      tasty tips really nice super blog 

    • web design bangalore 1:49 pm on August 4, 2011 Permalink

      tasty tips really nice super blog 

    • Philippines web designers 1:31 pm on September 12, 2011 Permalink

      Judging by the way it looks I’m sure it will taste really good! Bon Appetit!

    • Ankit Sharma 9:13 am on September 29, 2011 Permalink

             I am very happy to
      read your articles it’s very useful for me, 

      and I am completely satisfied with your
      website. 

      All comments and articles are very useful
      and very good.

      Your blog is very attention-grabbing. I
      am loving all of the in

       turn you are sharing with each one!…

      Website
      Designing in Indore
          

    • website development 5:42 pm on October 13, 2011 Permalink

      good recipe

    • website development 5:42 pm on October 13, 2011 Permalink

      good recipe

    • Hire PHP Programmer 1:16 pm on December 16, 2011 Permalink

      This is a nice content.You can get step-by-step assistance from our
      experienced website.Your written skill is really amazing.I appreciate to this
      one.This provide a good information.Thanks to share this blog.

    • Web Development 12:34 pm on January 1, 2012 Permalink

      Nice contentc.

    • Guaranteed Seo Services 6:20 pm on February 20, 2012 Permalink

      Amazing  recipe you know my mouth is melting..

    • Website Redesigning Company 5:41 am on March 14, 2012 Permalink

      This is a awesome articles.You can get step-by-step support from our
      experienced web page.Your published expertise is really awesome.I appreciate to this one.This offer a reliable details.Thanks to reveal this web page.

    • Robin wilson 10:30 am on March 26, 2012 Permalink

       
      Quite interesting
      and different post.. Keep posting..Stay blessed!!

      Hire php developers

  • britg 11:45 am on July 17, 2011 Permalink | Log in to leave a Comment
    Tags: , ,   

    Complex Gesture Recognition: Understanding the Score 

    I’ve had a few inquiries about the score that’s passed to the glyph detection delegate via

    -(void)glyphDetected:(WTMGlyph *)glyph withScore:(float)score

    in the MultistrokeGestureRecognizer iOS library.

    Here are a few key points about the score and the recognizer in general:

    • Calling detectGlyph will always return a match!
    • The match returned has a score (float) associated with it
    • The higher the score, the better
    • There’s no absolute scale as to what determines a “good” match

    As an example, if your only template glyph is a circle and the user draws a squiggly line, a call to detectGlyph will still return a match to your only template. The score will most likely be very low since the two gestures don’t resemble each other. Ultimately, it’s up to you and your application to determine what is a good match and whether to accept the input as a match or not.

    Behind the scenes, the N Dollar Recognizer is assigning a score to every template, but only the highest score is returned to the delegate.

    So, there’s no magical threshold in the score that determines a match. You’ll have to seed your templates and then do some testing, and your particular implementation will have to define score thresholds.

     
  • britg 10:00 am on July 4, 2011 Permalink | Log in to leave a Comment
    Tags: ,   

    New Relic Menu Bars: Multiple Application Support 

    Many of you use New Relic to monitor multiple accounts and applications, so I’ve updated New Relic Menu Bars to support these.

    Grab the updated version here.

    The New Relic API is pretty straight forward with regards to listing Accounts and Applications, but I personally don’t have this use-case. So, please let me know if the current implementation is lacking any functionality for those of you that do!

     
  • britg 10:10 pm on June 21, 2011 Permalink | Log in to leave a Comment
    Tags: ,   

    New Relic Menu Bar Performance Monitoring App 

    New Relic has quickly become an invaluable tool for monitoring performance of Key Ring for me. I found myself constantly checking the dashboard, partly for the graph, but mostly for the quick metrics at the top. Namely, I pay the most attention to requests-per-minute, response time, and errors.

    Why keep a browser window dedicated to this? Fortunately, New Relic provides an API, so I whipped together a quick and dirty menu bars app to display the stuff I care about. Here’s what it looks like:

    If you’d find this useful, feel free to download the app here.

    Warning: The app is very simple. It prompts you for your New Relic API key and then loads your first Account and first Application. Perfect for my needs, but I’m open to suggestions. Do a lot of you have multiple accounts or applications? If so, I can add an account/application selector.

    Update: I’ve added support for multiple accounts and applications. Get the new version here!

    Feel free to contact me a brit at britg dot com with suggestions or feature requests!

     
    • Diego Plentz 2:03 pm on June 22, 2011 Permalink

      Put it on github :)

    • Diego Plentz 2:03 pm on June 22, 2011 Permalink

      Put it on github :)

    • Diego Plentz 2:04 pm on June 22, 2011 Permalink

      Put it on github :)

    • Diego Plentz 2:04 pm on June 22, 2011 Permalink

      Put it on github :)

    • britg 2:43 pm on June 22, 2011 Permalink

      Thanks! I’m planning to add a few more features and put it on the Mac App Store. If that doesn’t work out, I’ll share it on github for sure. In the mean time,  you can check out this older project that’s open source: https://github.com/crossforward/rpm-status

    • britg 2:43 pm on June 22, 2011 Permalink

      Thanks! I’m planning to add a few more features and put it on the Mac App Store. If that doesn’t work out, I’ll share it on github for sure. In the mean time,  you can check out this older project that’s open source: https://github.com/crossforward/rpm-status

    • Christophe Porteneuve 3:49 pm on June 30, 2011 Permalink

      Hey Brit,

      Excellent stuff. However, IMHE most people using RPM monitor multiple apps indeed, so an app/host selector would be a top requirement (I, for one, monitor 25+ apps across 3 accounts).

    • Christophe Porteneuve 3:49 pm on June 30, 2011 Permalink

      Hey Brit,

      Excellent stuff. However, IMHE most people using RPM monitor multiple apps indeed, so an app/host selector would be a top requirement (I, for one, monitor 25+ apps across 3 accounts).

    • Gerred 4:37 pm on June 30, 2011 Permalink

      I’d love multiple accounts.

    • Gerred 4:37 pm on June 30, 2011 Permalink

      I’d love multiple accounts.

    • Steve Shapero 5:41 pm on June 30, 2011 Permalink

      looks cool – os x 10.6+ only?

    • Steve Shapero 5:41 pm on June 30, 2011 Permalink

      looks cool – os x 10.6+ only?

    • britg 1:19 am on July 1, 2011 Permalink

      Thanks! Ok, good to know. I’ll work on multiple account management next!

    • britg 1:19 am on July 1, 2011 Permalink

      Thanks! Ok, good to know. I’ll work on multiple account management next!

    • britg 1:20 am on July 1, 2011 Permalink

      I don’t know, as I’m only running 10.6 — Let me know if you’re running something else and it doesn’t work.

    • britg 1:20 am on July 1, 2011 Permalink

      I don’t know, as I’m only running 10.6 — Let me know if you’re running something else and it doesn’t work.

    • Marshall Yount 4:22 pm on July 1, 2011 Permalink

      Dead sexy!

    • whatafy 12:45 pm on July 8, 2011 Permalink

      Very cool, thanks! 

    • Manoj Kumar 3:36 am on October 28, 2011 Permalink

      Muay Thai gear for training purposes, you may want to consider MMA
      equipment instead. It does not matter if you are studying Krav Maga,
      Kick Boxing, Judo, Karate or Jiu Jitsu the world of mixed martial arts
      have given us big benefits.muay thai training in thailand
       

    • Web design London 7:21 pm on December 29, 2011 Permalink

      I’m planning to add a few more features and put it on the Mac App Store. If that doesn’t work out, I’ll share it on github for sure.

    • Kids Summer Camp 6:52 pm on March 23, 2012 Permalink

      I love it! Great job!

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
esc
cancel