Search Results

Search found 40 results on 2 pages for 'rexonroids'.

Page 2/2 | < Previous Page | 1 2 

  • How to tell if you touched a CCLabel? (Cocos2d Question)

    - by RexOnRoids
    How to tell if you touched a CCLabel? The following code obviously does not work well enough because it only tests for point equality. Naturally touch point will not necessarily be equal to the position property of the CCLabel (CCNode). How to I tell if a Touch point has fallen within the "rectangle?" of the CCLabel? - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { for( UITouch *touch in touches ) { CGPoint location = [touch locationInView: [touch view]]; location = [[CCDirector sharedDirector] convertToGL:location]; self.myGraphManager.isSliding = NO; if(CGPointEqualToPoint(location, label1.position)){ NSLog(@"Label 1 Touched"); }else if(CGPointEqualToPoint(location, label2.position)){ NSLog(@"Label 2 Touched"); }else if(CGPointEqualToPoint(location, label3.position)){ NSLog(@"Label 3 Touched"); }else if(CGPointEqualToPoint(location, label4.position)){ NSLog(@"Label 4 Touched"); }else if(CGPointEqualToPoint(location, label5.position)){ NSLog(@"Label 5 Touched"); }else if(CGPointEqualToPoint(location, label6.position)){ NSLog(@"Label 6 Touched"); } NSLog(@"Touch Made!"); } }

    Read the article

  • How to stop OpenGL from applying blending to certain content? (see pics)

    - by RexOnRoids
    Supporting Info: I use cocos2d to draw a sprite (graph background) on the screen (z:-1). I then use cocos2d to draw lines/points (z:0) on top of the background -- and make some calls to OpenGL blending functions before the drawing to SMOOTH out the lines. Problem: The problem is that: aside from producing smooth lines/points, calling these OpenGL blending functions seems to "degrade" the underlying sprite (graph background). As you can see from the images below, the "degraded" background seems to be made darker and less sharp in Case 2. So there is a tradeoff: I can either have (Case 1) a nice background and choppy lines/points, or I can have (Case 2) nice smooth lines/points and a degraded background. But obviously I need both. THE QUESTION: How do I set OpenGL so as to only apply the blending to the layer with the Lines/Points in it and thus leave the background alone? The Code: I have included code of the draw() method of the CCLayer for both cases explained above. As you can see, the code producing the difference between Case 1 and Case 2 seems to be 1 or 2 lines involving OpenGL Blending. Case 1 -- MainScene.h (CCLayer): -(void)draw{ int lastPointX = 0; int lastPointY = 0; GLfloat colorMAX = 255.0f; GLfloat valR; GLfloat valG; GLfloat valB; if([self.myGraphManager ready]){ valR = (255.0f/colorMAX)*1.0f; valG = (255.0f/colorMAX)*1.0f; valB = (255.0f/colorMAX)*1.0f; NSEnumerator *enumerator = [[self.myGraphManager.currentCanvas graphPoints] objectEnumerator]; GraphPoint* object; while ((object = [enumerator nextObject])) { if(object.filled){ /*Commenting out the following two lines induces a problem of making it impossible to have smooth lines/points, but has merit in that it does not degrade the background sprite.*/ //glEnable (GL_BLEND); //glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glEnable (GL_LINE_SMOOTH); glLineWidth(1.5f); glColor4f(valR, valG, valB, 1.0); ccDrawLine(ccp(lastPointX, lastPointY), ccp(object.position.x, object.position.y)); lastPointX = object.position.x; lastPointY = object.position.y; glPointSize(3.0f); glEnable(GL_POINT_SMOOTH); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); ccDrawPoint(ccp(lastPointX, lastPointY)); } } } } Case 2 -- MainScene.h (CCLayer): -(void)draw{ int lastPointX = 0; int lastPointY = 0; GLfloat colorMAX = 255.0f; GLfloat valR; GLfloat valG; GLfloat valB; if([self.myGraphManager ready]){ valR = (255.0f/colorMAX)*1.0f; valG = (255.0f/colorMAX)*1.0f; valB = (255.0f/colorMAX)*1.0f; NSEnumerator *enumerator = [[self.myGraphManager.currentCanvas graphPoints] objectEnumerator]; GraphPoint* object; while ((object = [enumerator nextObject])) { if(object.filled){ /*Enabling the following two lines gives nice smooth lines/points, but has a problem in that it degrades the background sprite.*/ glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glEnable (GL_LINE_SMOOTH); glLineWidth(1.5f); glColor4f(valR, valG, valB, 1.0); ccDrawLine(ccp(lastPointX, lastPointY), ccp(object.position.x, object.position.y)); lastPointX = object.position.x; lastPointY = object.position.y; glPointSize(3.0f); glEnable(GL_POINT_SMOOTH); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); ccDrawPoint(ccp(lastPointX, lastPointY)); } } } }

    Read the article

  • How do I switch between Navigation Controllers?

    - by RexOnRoids
    Situation: I have an Xcode project based on the "Navigation-Based-Application" template. So that means I have a SINGLE UINavigationController that manages a UIViewController. What I want To Do: What I want to do is add one more UINavigationController to my project -- and be able to switch back and forth between them. (I want to do this to make space for some seperate unrelated content so that it does not have a back button pointing back to the root view controller.) Question: How do I add one more UINavigationController to my project and switch between the two UINavigationControllers?

    Read the article

  • How are people popping their UINavigationController stacks under a UITabBarController?

    - by RexOnRoids
    I have four UINavigationControllers assigned each to a tab in a UITabBarController. Each UINavigationController manages a UIViewController, which may itself branch out into other UIViewControllers below it hierarchally. My question is, in a case in which a user, under one tab, has navigated to a UIViewController that hierarchally BELOW the main UIViewController managed by the UINavigationController, and then the user pushes a different tab, and then goes back to the original tab, HOW can I make it so that the user is presented with the main UIViewController managed by the UINavigation controller? and not the page where he left off?

    Read the article

  • What are your experiences selling on the Android Market?

    - by RexOnRoids
    I've been hearing some good things about Google's Android Market recently, and I might look into developing for android (currently develop for iPhone OS) at some point. Are any of you Android Developers, or simultaneously developing for iPhone AND Android? What have your experiences been for developing and selling your apps on the Android Market? Does Google have their act together in their app approval/deployment process? How does being a developer/merchant on the Android Market compare with the that of the App Store? Are you making money? Do you see this market as promising? Love it? Hate it? Share your experiences on the Android Market.

    Read the article

  • "Single NSMutableArray" vs. "Multiple C-arrays" --Which is more Efficient/Practical?

    - by RexOnRoids
    Situation: I have a DAY structure. The DAY structure has three variables or attributes: a Date (NSString*), a Temperature (float), and a Rainfall (float). Problem: I will be iterating through an array of about 5000 DAY structures and graphing a portion of these onto the screen using OpenGL. Question: As far as drawing performance, which is better? I could simply create an NSMutableArray of DAY structures (NSObjects) and iterate on the array on each draw call -- which I think would be hard on the CPU. Or, I could instead manually manage three different C-Arrays -- One for the Date String (2-Dimensional), One for the temperature (1-Dimensional) and One for the Rainfall (1-Dimensional). I could keep track of the current Day by referencing the current index of the iterated C-Arrays.

    Read the article

  • Why do touches only get detected ABOVE my CCBitmapFontAtlas and not ON it? (cocos2d)

    - by RexOnRoids
    I am detecting touches for CCBitmapFontAtlas (just text labels) as shown in the code below. But it seems that touches are only detected slightly ABOVE the CCBitmapFontAtlases? Did something get screwed when converting between coordinate systems? (*Note objects label1, label2, etc are CCBitmapFontAtlas) - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { for( UITouch *touch in touches ) { CGPoint location = [touch locationInView:[touch view]]; location = [[CCDirector sharedDirector] convertToGL:location]; self.myGraphManager.isSliding = NO; CGRect rectLabel1 = CGRectMake(label1.position.x, label1.position.y, label1.contentSize.width, label1.contentSize.height); CGRect rectLabel2 = CGRectMake(label2.position.x, label2.position.y, label2.contentSize.width, label2.contentSize.height); CGRect rectLabel3 = CGRectMake(label3.position.x, label3.position.y, label3.contentSize.width, label3.contentSize.height); CGRect rectLabel4 = CGRectMake(label4.position.x, label4.position.y, label4.contentSize.width, label4.contentSize.height); CGRect rectLabel5 = CGRectMake(label5.position.x, label5.position.y, label5.contentSize.width, label5.contentSize.height); CGRect rectLabel6 = CGRectMake(label6.position.x, label6.position.y, label6.contentSize.width, label6.contentSize.height); if(CGRectContainsPoint(rectLabel1, location)){ NSLog(@"Label 1 Touched"); }else if(CGRectContainsPoint(rectLabel2, location)){ NSLog(@"Label 2 Touched"); }else if(CGRectContainsPoint(rectLabel3, location)){ NSLog(@"Label 3 Touched"); }else if(CGRectContainsPoint(rectLabel4, location)){ NSLog(@"Label 4 Touched"); }else if(CGRectContainsPoint(rectLabel5, location)){ NSLog(@"Label 5 Touched"); }else if(CGRectContainsPoint(rectLabel6, location)){ NSLog(@"Label 6 Touched"); } } }

    Read the article

  • How to get the location (x,y) of a CCLabel that is a child of a CCScene?

    - by RexOnRoids
    (learning Cocos2D) After creating a CCLabel and adding it to a CCLayer like this: //From HelloWorldScene.m // create and initialize a Label CCLabel* label1 = [CCLabel labelWithString:@"Hello" fontName:@"Marker Felt" fontSize:10]; label1.position = ccp(35, 435); // add the label as a child to this Layer [self addChild: label1]; How do I determine when a user has TOUCHED the label on the screen?

    Read the article

  • How to calculate the y-pixels of someones weight on a graph? (math+programming question)

    - by RexOnRoids
    I'm not that smart like some of you geniuses. I need some help from a math whiz. My app draws a graph of the users weight over time. I need a surefire way to always get the right pixel position to draw the weight point at for a given weight. For example, say I want to plot the weight 80.0(kg) on the graph when the range of weights is 80.0 to 40.0kg. I want to be able to plug in the weight (given I know the highest and lowest weights in the range also) and get the pixel result 400(y) (for the top of the graph). The graph is 300 pixels high (starts at 100 and ends at 400). The highest weight 80kg would be plot at 400 while the lowest weight 40kg would be plot at 100. And the intermediate weights should be plotted appropriately. I tried this but it does not work: -(float)weightToPixel:(float)theWeight { float graphMaxY = 400; //The TOP of the graph float graphMinY = 100; //The BOTTOM of the graph float yOffset = 100; //Graph itself is offset 100 pixels in the Y direction float coordDiff = graphMaxY-graphMinY; //The size in pixels of the graph float weightDiff = self.highestWeight-self.lowestWeight; //The weight gap float pixelIncrement = coordDiff/weightDiff; float weightY = (theWeight*pixelIncrement)-(coordDiff-yOffset); //The return value return weightYpixel; }

    Read the article

< Previous Page | 1 2