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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:35:00+00:00 2026-06-17T12:35:00+00:00

We’re currently developing a game involving graphs (nodes connected by edges), and we want

  • 0

We’re currently developing a game involving graphs (nodes connected by edges), and we want to be able to move the nodes around. We have the nodes moving (responding to touch), but when the edges (initialized with .png images) are re-rendered as a result of the nodes moving, they look jagged. We’ve tried playing around with Aliasing and Anti-Aliasing, but the edges are jagged regardless of what we do.

Here’s where we initialize the edge images (with image file):

-(id) initWithSet:(int)setNum Level:(int) levelNum
{
    if( (self=[super init]) ) {

           <code omitted>

           for (NSArray *e in self.level.targetGraph) {

               <code omitted>

               CCSprite *edgeOutline = [CCSprite spriteWithFile:@"EdgeOutline.png"];
               [edgeOutline setPosition:ccp((ax+bx)/2, (ay+by)/2)];
               edgeOutline.scaleX = (dist * edgeOutline.scaleX)/edgeOutline.contentSize.width;
               edgeOutline.scaleY = (self.nodeSize * 0.5 * edgeOutline.scaleY)/edgeOutline.contentSize.height;
               edgeOutline.rotation = -angle;
               [outlines addChild:edgeOutline];

               CCSprite *edgeFill = [CCSprite spriteWithFile:@"EdgeFill.png"];
               [edgeFill setPosition:ccp((ax+bx)/2, (ay+by)/2)];
               edgeFill.scaleX = (dist * edgeFill.scaleX)/edgeFill.contentSize.width;
               edgeFill.scaleY = (self.nodeSize * 0.4 * edgeFill.scaleY)/edgeFill.contentSize.height;
               edgeFill.rotation = -angle;
               [fills addChild:edgeFill];

         }

  return self;
}

And here’s where we update the edge drawings (using the second half of the nextFrame method):

- (void) nextFrame:(ccTime)dt {

    for (NSArray *e in self.level.graph) {
        CCSprite *a = [self.graphNodeOutlines objectForKey:[e objectAtIndex:0]];
        double ax = a.position.x;
        double ay = a.position.y;
        CCSprite *b = [self.graphNodeOutlines objectForKey:[e objectAtIndex:1]];
        double bx = b.position.x;
        double by = b.position.y;

        double dx = ax-bx;
        double dy = ay-by;
        double angle = 90;
        if (dx != 0) {
            angle = atan2(ay-by, ax-bx)*180/M_PI;
        }
        double dist = sqrt(dx*dx+dy*dy);

        //TODO: get anti-aliasing to work in this next part!

        CCSprite *edgeOutline = [self.graphEdgeOutlines objectForKey:e];
        [edgeOutline setPosition:ccp((ax+bx)/2, (ay+by)/2)];
        edgeOutline.scaleX = (dist)/edgeOutline.contentSize.width;
        edgeOutline.scaleY = (self.nodeSize * 0.25)/edgeOutline.contentSize.height;
        edgeOutline.rotation = -angle;

        //The line we hoped would fix the jagged edge problem.
        [[edgeOutline texture] setAntiAliasTexParameters];

        CCSprite *edgeFill = [self.graphEdgeFills objectForKey:e];
        [edgeFill setPosition:ccp((ax+bx)/2, (ay+by)/2)];
        edgeFill.scaleX = (dist)/edgeFill.contentSize.width;
        edgeFill.scaleY = (self.nodeSize * 0.2)/edgeFill.contentSize.height;
        edgeFill.rotation = -angle;

        //The (same) line we hoped would fix the jagged edge problem.
        [[edgeFill texture] setAntiAliasTexParameters];

    }
}

We’re using Cocos2D v2.0 and XCode v4.5.

Any help would be greatly appreciated. Thank you!

UPDATE: A picture showing the issue:

enter image description here

  • 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-17T12:35:01+00:00Added an answer on June 17, 2026 at 12:35 pm

    I have a solution! Follow the “Adding a MainWindow.xib” section of this tutorial: http://www.raywenderlich.com/4817/how-to-integrate-cocos2d-and-uikit

    Somehow, handing some of the graphics responsibility over to UIKit solves the problem. Ray is my savior.

    EDIT: This only seems to fix the problem on the ipad. No idea why.

    EDIT 2: Ignore all that; all antialiasing had something to do the simulator scaling. Instead, help me figure out what this post means: http://www.cocos2d-iphone.org/forum/topic/4773

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.