Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
LP0 ON FIRE
Jan 25, 2006

beep boop
In Cocos2D, I seem to have an issue with setting a sprites visibility to YES and NOT seeing the results immediately after a method call that hangs everything for a bit. It seems as though a frame draw has to occur, but this doesn't happen because the method call stops everything for a bit which makes it very noticeable. (There is no sprite in sight even though there should be)

Does anyone know how to force a frame draw in Cocos2D? I think this my problem. Calling update (my CCScheduler method) would probably just cause an infinite loop, and maybe there's some way I could circumvent this, but it's just going to get messy. I've also tried making the visibility YES right before the method is called, but that does not make it show up either.

LP0 ON FIRE fucked around with this message at 22:37 on Dec 2, 2011

Adbot
ADBOT LOVES YOU

LP0 ON FIRE
Jan 25, 2006

beep boop
When I switch tabs in Xcode, sometimes it's scrolled to totally the wrong position. I have to go up to the method selection and select it. Does anyone know what's going on here? Am I doing something wrong, or is it just a bug?

LP0 ON FIRE
Jan 25, 2006

beep boop
I'm reposting a question asked on the Cocos2D forum, since it is quite a complicated issue and there are more posters here.

I have a sprite added from a method call in init using convertToNodeSpace, and it is placing it incorrectly. I use practically use the same code elsewhere to place sprites with convertToNodeSpace (placing it in the center of the iPad screen) and it works fine.

My guess is before init returns self, convertToNodeSpace cannot make an accurate conversion. Is this the problem most likely, and is there any known solutions?

LP0 ON FIRE
Jan 25, 2006

beep boop

Carthag posted:

So it looks like at different points in the sprite's lifetime, convertToNodeSpace behaves differently? I haven't used cocos2d, but have you tested this (in the same object)? Like putting the conversion later on, and seeing if it gives a different result than during init?

I am trying to get out of the habit of NSLog-debugging, but sometimes that's just the easiest. Logging what it does during init, and then later on, and comparing...

Exactly. It gives a different result if I use convertToNodeSpace later on and outside of init. I heard that it's a problem that I'm calling it on a node that does not yet have a parent. There has to be an alternate way of getting the center coordinates of the iPad/iPhone screen area (not the entire current map) and placing the sprite there.

edit: Fixed it! I have my method call to place this sprite right before return self in init. Somehow that works.

LP0 ON FIRE fucked around with this message at 20:14 on Jan 20, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop
For the most part I'm used to writing applications for iOS, but I just started experimenting making stuff for OS X. I'm trying to make a simple video player and followed this tutorial with slightly different names for files.

I try opening a MOV file from my application I built, and nothing happens. I can't figure out what's wrong. For anyone that wants to help and check out my project, It's very cut and dry, so someone that's knowledgeable with this stuff I'm sure can easily track it down.

In my console, before I even open anything I receive the waring several times "Unable to read symbols for cl_kernels (file not found)."

LP0 ON FIRE
Jan 25, 2006

beep boop
Thanks Doc Block! I started off the wrong kind of project with just a delegate, so everything became kind of twisted when I followed this tutorial. I should have started from scratch, but I also wanted to learn what was wrong since most of the experience I have is without using interface builder. I'm deciding to learn not to hate it and give it a try.

LP0 ON FIRE
Jan 25, 2006

beep boop

duck monster posted:

gently caress coder machismo. Interface builder is awesome, once you get the hang of it.

People who like coding interfaces by hand are wierd to my thinking.

I bet it is, but it's sort of over my head to make a ton of crazy connections to buttons that have tweened animation, may or may not be displaying, and sliding transitions into other views, etc, which is exactly what I needed to create for my first app. It was enough pressure that I was just learning Obj-C, and then decided whether or not it was really worth creating a nib for something like a movie player, which would just be a feature that would be recycled throughout the program with different filenames. I can see where it would be really beneficial, like if you had a lot of carefully placed sliders, and it would be much easier to draw those out on a space. But usually I'm going from something like a design from Photoshop and getting button coordinates and then just hardcoding them. It's not that I really like coding interfaces, but sometimes factoring in IB seems like unnecessary extra work.

LP0 ON FIRE
Jan 25, 2006

beep boop

duck monster posted:

The whole deal with iOS and mac interfaces is they should be simple and as apple-y looking as possible. IF its compliant, your coding in a propper model-view-controller pardgim and are not rolling whats already provided, then chances are your IB <-> Code relationship will be simple.

Unless your doing a game, in which case carry on... (Its the one thing I wouldnt use IB on , cos I'd rather use Cocos2d)

I wish I could have made it Apple-y looking, but it wouldn't have lived up to the expectations of the client. Other than that, it still followed the model-view-controller guidelines. And for the past 11 months I've been working on a game in Cocos2D, so I STILL haven't had any experience really using interface builder! Just now I'm trying to get my feet wet in IB with some personal projects.

Doc Block posted:

And with IB you also have the added advantage of immediate feedback if you want to tweak an element's attributes or placement.

I agree, and it will probably help out a lot with what I'm making now.

LP0 ON FIRE
Jan 25, 2006

beep boop
Is it safe to call just [self methodName:] on a method that has only a BOOL parameter? I'm using it on a selector in Cocos2D like this: id actionRestoreEnergy = [CCCallFuncN actionWithTarget:self selector:@selector(restoreHeroEnergy:)];

The only reason I want to do it this way is because that selector doesn't need to send a YES message in that particular instance, and I don't feel like doing all the data stuff and changing my method because it seems like it does the same thing as long as it's not causing leaks to memory and such.

edit: Actually this is bad because it is always returning YES with just restoreHeroEnergy:

LP0 ON FIRE fucked around with this message at 19:25 on Feb 3, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop

Gordon Cole posted:

If the value of the argument doesn't matter, why not just pass in an arbitrary value instead of not passing anything and hoping it works? If you want to make it clear that the parameter doesn't matter in this case, make another method called restoreHeroEnergy that doesn't take any argument and just calls the actual method with a default value.

I imagine that what's actually happening is that self is being passed in as the parameter, which evaluates to true since it isn't null. If you need the value of the parameter to be NO then just pass in NO.

In my case I'm using selector, and if I did want to send any kind of message it would look something like this: [CCCallFuncND actionWithTarget:self selector:@selector(restoreHeroEnergy : data:) data:[[NSNumber numberWithBool:NO] retain]];

And then I'd need to edit the restoreHeroEnergy method and also take into account to release that NSNumber. I guess not such a big deal but why make things look more messy if restoreHeroEnergy in that selector.. but I now know that's not the case.

LP0 ON FIRE fucked around with this message at 20:52 on Feb 3, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop

Gordon Cole posted:

I've never used Cocos2D so I'm probably missing something here, but what's the purpose of calling the method that way rather than doing [self restoreHeroEnergy: NO]?

Good question. I should have cleared that up first. CCCallFuncN can be used on an action definition to be run in a certain sequence with the runAction method. Actions can be used on sprites to move to a certain location, fade out, etc, and then a function action can be run anytime in that sequence to call methods. CCCallFuncN doesn't support just passing any type of parameter, so you need to set it in node data.

LP0 ON FIRE
Jan 25, 2006

beep boop
Since my entire scene in cocos2D gets replaced during transitions when I still need a text layer to stay unaltered, I needed to abandon cocos2D sprite text for that layer. I added a UIView in front tested the replacement with a UILabel, and everything is running smoothly. But this a UILabel...not outlined sprite text.

Does anyone know of some handy code or framework that would work as a good sprite text replacement that can be shown in a UIView?

LP0 ON FIRE
Jan 25, 2006

beep boop
With lots of trial and error, I ended up making my own method to stroke text with some amazing results. I expected this to run slowly because it sometimes renders text with a stroke as a UIImage many times per second.


code:
-(void) renderTetraCount {
    
// I made my UIImageView in init. I can remove it here over and over.

    [textIMGView removeFromSuperview];
    
    UIImage *textIMG = [self outlineText:[NSString stringWithFormat:@"%d", tetraCount]];
    
    textIMGView = [[UIImageView alloc] initWithImage:(UIImage *)textIMG];
    CGRect headerFrame = textRect2;
    textIMGView.frame = headerFrame;
    [self addSubview:textIMGView]; 
    textIMGView.image = textIMG; 
    
    [textIMGView release];
    
}
code:
-(UIImage *)outlineText:(NSString *)text{
    
    UIFont *font = [UIFont fontWithName:@"Arial-BoldMT" size:22.0];  
    
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(txtWidth, txtHeight),NO,0.0);
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    //draw stoke first
    CGContextSetLineWidth(context, 4);
    CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0);
    CGContextSetTextDrawingMode(context, kCGTextStroke);
    CGContextSaveGState(context);
    [text drawAtPoint:CGPointMake(2,0) withFont:font];
    
    //then draw fill on top of stroke
    CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
    CGContextSetTextDrawingMode(context, kCGTextFill);
    CGContextSaveGState(context);
    [text drawAtPoint:CGPointMake(2,0) withFont:font];
    
    //send image
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();    
    
    return image;
}
It does not seem to impede on my game's performance whatsoever, even with large fonts. Other than that, feel free to mention if you see anything weird with my code.

LP0 ON FIRE
Jan 25, 2006

beep boop
Thanks Doc Block. I didn't realize I could just keep using that same UIImageView. I'll try that out tomorrow. Also it does only create a new image only if tetraCount changes, and not every frame.

LP0 ON FIRE
Jan 25, 2006

beep boop
I need a good tool to create "virtual tour" 360° view panoramas, complete with hotspots to go to a new location or view a photo for iOS only. I found a couple that blew me away with their demos, but after downloading the trial versions I wasn't so pleased:

KRPano - The tools are just droplets that you can drag and drop images to. No tool that has a UI that I can see, which would actually make things like placing hotspots do-able.

Easypano - Pano tool crashes 4/5 times that I attempt to publish. Don't see any way to place hotspots, but maybe I downloaded the wrong version.

Any suggestions?

LP0 ON FIRE fucked around with this message at 20:19 on Feb 24, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop
Sorry I forgot to mention I need something for iOS. Photosynth is cool, but I thought it was limited to being made up of a bunch of pictures you take with your phone. I need a tool where you can import an entire panorama and view it and create hotspots for navigation, etc.

edit: Panotour Pro seems pretty amazing to work with, but I can't test for iOS unless I buy the full version.

LP0 ON FIRE fucked around with this message at 21:22 on Feb 24, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop
I'm in one of these moments where I'm doing something completely retarded but I'm absolutely stumped. I'm just trying to load my html into my UIWebView with the correct baseURL so that I can use relative paths.

code:
    NSString *path = [[NSBundle mainBundle] bundlePath];
    NSURL *baseURL = [NSURL fileURLWithPath:path];
    [webView loadHTMLString:@"tour.html" baseURL:baseURL];
It just shows the text "tour.html" inside my UIWebView..

LP0 ON FIRE
Jan 25, 2006

beep boop

pokeyman posted:

code:
NSURL *urlToTourHTML = ...;
NSError *error;
NSString *tourHTML = [NSString stringWithContentsOfURL:urlToTourHTML
                                              encoding:NSUTF8StringEncoding
                                                 error:&error];
if (tourHTML)
    [webView loadHTMLString:tourHTML];
else
    handle error
or use -loadRequest: on the UIWebView.

Carthag posted:

You're having the webView show the actual HTML string "tour.html", not the file by that name. It's for doing things like loadHTMLString:@"<html>blahblah</html>"

You want something like:

[webView setMainFrameURL:[[NSBundle mainBundle] pathForResource:@"tour" oFType:@"html"]];

Thank you. I ended up going with
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"tour" ofType:@"html"]isDirectory:NO]]];

And then I had many hardships with adding folders the correct way and trying to figure out why my javascript wouldn't work in my UIWebView.

I hope someone reading this will save themselves some time in case they don't know:

1.) When dragging folders in that you want a UIWebView to reference as offline data, make sure you click the "Create folder references for any added folders" radio button.

2.) Any javascript files on the root level of resources (not in a folder) will be compiled by Xcode. In most cases you don't want this to happen if the UIWebView depends on using it just as a website would. You need to drag the javascript files from your Compile Sources in Build Phases into Copy Bundle Resources.

Now everything works great!

LP0 ON FIRE
Jan 25, 2006

beep boop

Doc Block posted:

If you don't need JavaScipt or anything really complex but just want the ability to show formatted text with images and links, and still be able to have it fit the look of your app then give DTCoreText a shot.

Way better performance-wise that having to pull in a UIWebView.

Cool, good to note. I'm actually using KRPano made from Panotour Pro to view virtual tours. The challenge was doing this offline with UIWebView so that I can include it in an app that can do other things than just view the virtual tours. Other people are using GoodReader, which is lame to me because that means I can't use my virtual tours in an app that runs offline.

LP0 ON FIRE
Jan 25, 2006

beep boop
I have an enterprise provision mess on my shoulders right now. The company that I made an enterprise iPad app for did not renew their provision nor their account. As soon as they paid for a new yearly fee, I had access to their account but the provision was expired. There was no renew button, and the distribution certificate was gone from the portal. So I removed the provision, and made one with the same name and another certificate that associated with that provision, downloaded those both and synced with my iPad. And of course, the app does not launch, and why would I expect it to since the app is associated with the old provision..

So the disaster here is that there's around 100 iPads around the world with this app on it. Do I really need to rebuild the app with the new certificate and it pointing to the correct provision in the build settings? If that's true I'll have to redistribute it. I'd rather just send everyone a new provision.

Another thing is that I thought this provision was never supposed to expire. It's not an Ad Hoc but an In House provision.

In organizer my new in house provision says it does not have a valid signing identity even though it's paired with my new certificate that I downloaded.
Restarted organizer and that issue cleared up. But I still can't figure out a way to make this work without making a new build.

Enterprise distribution has been a nightmare to me. Ultimately, if none of this works without making a new build, I'd like to know a way of distributing enterprise apps without having poo poo expire.

LP0 ON FIRE fucked around with this message at 19:15 on Mar 13, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop
drat... I just upgraded my work's iPad to iOS 5.1, and it seems that I can no longer test on this device unless I upgrade to Lion to install the new Xcode. I get this when I try to run:



Am I right about that?

LP0 ON FIRE
Jan 25, 2006

beep boop

duck monster posted:

Set up hockeykit on a server somewhere and do that. Its a pain in the arse, but its a tonne easier than trying to coordinate 100+ dumb arses to correctly set up their devices. plus the auto over-the-air updates solves it for future instances too.

http://hockeykit.net/

Ugh.. yeah the problem with this or any solution like downloading is that the app is about 2 GB. In some places internet connection is really poor so this just wouldn't be satisfactory. We tested it and the app downloading and installing can take a half a day or more in some places.


Hog Obituary posted:

You need Xcode 4.3.1 to develop/debug with iOS 5.1, yes.

That sucks :(

I guess I will have to convince them to upgrade my computer even though it is very cheap. It's just that a lot of software we run is not compatible with Lion. I was pointed to some other solutions on Stack Overflow, but they are very hacky look like a pain to incorporate. May as well upgrade my OS X.

LP0 ON FIRE fucked around with this message at 01:50 on Mar 14, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop

duck monster posted:

how the gently caress did you make a 2Gb app? :confused:

e: Also yeah, feel your pain with the Lion upgrade. I was forced to upgrade due to Xcode , but it took 9months for loving Zoom to release drivers for my audio recording interface. Total cuntitude all around.

The bulk of it consists of high quality videos that can also be displayed on a TV when the iPad is connected to it, so they have to look good scaled up. The videos are still pretty well compressed, there's just a lot of them.

Yeah, so I'm just going to have to remember for next time that when I update my iOS, I may also have to update my OS X so I can install a new Xcode! Although this happens so far apart though I know I'll forget..

LP0 ON FIRE
Jan 25, 2006

beep boop
I know this might sound sort of arbitrary, but I thought my Cocos2D game with the 3rd generation iPad would take advantage of it's faster processor and give me a higher fps. It was running really well on the iPad 2 so I thought it would be pegging at 60fps all the time, but it seems to running the same as it was before. Are there any extra build settings I should change?

LP0 ON FIRE
Jan 25, 2006

beep boop

Doc Block posted:

It depends on what your game is doing, and how well optimized it is. If you have lots of overdraw then you're going to be fillrate limited, and with 4 times as many pixels to draw, things aren't going to be magically fixed.

The main goal with the iPad 3's GPU and CPU seems to have been to keep things at roughly the same framerate but at 4 times the resolution. Throwing 2 more cores into the GPU is a brute-force solution to improving GPU performance, and (I would think) mainly benefits fillrate.

Also, Cocos2D has some optimization issues, according to Instruments' OpenGL ES analyzer.

edit: it also depends on how recent your Cocos2D build is. The 1.1 and 2.0 betas get better performance, and don't have touch issues when using the DisplayLink director.

Hmm.. I think I understand. So by theory if my code is optimized and I'm not doing anything overzealous, my game should run about the same with retina graphics. I've been running v0.99.5, and I don't feel so comfortable upgrading since I've edited the framework so much. :geno:

LP0 ON FIRE
Jan 25, 2006

beep boop
I keep on getting pngcrush errors in Xcode (app builds anyway) from png images I saved for web and devices from Photoshop. They are transparent and NOT interlaced. I re-saved as png's in preview like the threads on StackOverflow suggested to no avail. Even though my app builds, it's only every so often that the build displays the images correctly.

edit: I had the same files in another directory in resources.. That'll do it.

LP0 ON FIRE fucked around with this message at 20:25 on Mar 30, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop
Cocos2D iOS: I'm having trouble accessing a parent method from a sprite class. A bunch of the sprite classes are put into a mutable array in the parent class. When a method is called in the child class a sort of timed call to the parent is called later on using CCCallFuncO. But even with a regular method call in the child class to parent won't work!

In the child's .h I have
code:
#import "JoinedMapsLayer.h"
@class JoinedMapsLayer;
And inside a method (not init) is:
code:
JoinedMapsLayer *joinedMapsLayer = (JoinedMapsLayer*)self.parent;
[joinedMapsLayer displayMessageBox:@"whatever"];
JoinedMapsLayer is my parent class. It's dead simple. Shouldn't it call displayMessageBox: if it exists and print out the NSLog inside of it? Nothing happens, no crash yet no log.

LP0 ON FIRE fucked around with this message at 17:30 on Apr 17, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop

pokeyman posted:

Stick a breakpoint on the line where you send -displayMessageBox: and check things out. Is joinedMapsLayer right object (i.e. not nil, right type)? Step into the method call. Does it go where you want?

I'm not sure where I would find if joinedMapsLayer is nil or not. I made a new method in joinedMapsLayer called test with no parameters and a NSLog inside. When I step into the the line [joinedMapsLayer test]; which is inside the child sprite class I get

code:
libobjc.A.dylib`objc_msgSend:
0x328a1f68:  teq.w  r0, #0
0x328a1f6c:  beq    0x328a1faa               ; objc_msgSend + 66
0x328a1f6e:  push.w {r3, r4}
0x328a1f72:  ldr    r4, [r0]
0x328a1f74:  lsr.w  r9, r1, #2
0x328a1f78:  ldr    r3, [r4, #8]
0x328a1f7a:  add.w  r3, r3, #8
0x328a1f7e:  ldr    r12, [r3, #-8]
0x328a1f82:  and.w  r9, r9, r12
0x328a1f86:  ldr.w  r4, [r3, r9, lsl #2]
0x328a1f8a:  teq.w  r4, #0
0x328a1f8e:  add.w  r9, r9, #1
0x328a1f92:  beq    0x328a1fa6               ; objc_msgSend + 62
0x328a1f94:  ldr.w  r12, [r4]
0x328a1f98:  teq.w  r1, r12
0x328a1f9c:  bne    0x328a217e               ; objc_msgSendSuper_stret + 34
0x328a1f9e:  ldr.w  r12, [r4, #8]
0x328a1fa2:  pop    {r3, r4}
0x328a1fa4:  bx     r12
0x328a1fa6:  pop    {r3, r4}
0x328a1fa8:  b      0x328a1fb0               ; objc_msgSend_uncached
0x328a1faa:  mov.w  r1, #0
0x328a1fae:  bx     lr
Even though that is a different method, that's where you wanted me to put a break and step into, right?

e:

Doc Block posted:

Check and see if self.parent is nil. If you're adding the child sprites to the array yourself, rather than using CCNode's addChild: method, then you'll have to set the child sprite's parent property yourself.

Wait, this is interesting.

LP0 ON FIRE
Jan 25, 2006

beep boop

pokeyman posted:

At the lldb prompt type po joinedMapsLayer

(CCNode *(*)(void)) $1 = 0x00041475 (Flying Adventure`-[JoinedMapsScene joinedMapsLayer] + 1 at JoinedMapsScene.m:15) [no Objective-C description available]

By the way Doc Block, I'm trying to look it up, but I don't know how to manually set a child sprite's parent property as of yet. I'm guessing it's really easy. I also need to make sure that this is the problem first.

LP0 ON FIRE
Jan 25, 2006

beep boop
Holy crap you guys are amazing. It would have taken me ages to figure this out by myself. In init, when I when I make a temporary pointer to an array index I just do:

tempHummingChar.parent = self;

Now it works!

LP0 ON FIRE
Jan 25, 2006

beep boop

Doc Block posted:

Not to be a jerk, but if the parent property wasn't set somewhere then yeah, it isn't going to work.

Also, is JoinedMapsLayer a descendent of CCNode? (if it's a descendent of CCLayer then it is). If so, you shouldn't need to make your own mutable array of sprites; each CCNode has its own array of all its children. Just do [joinedMapsLayer addChild:someSprite] or something and it will add it to joinedMapsLayer's CCArray and set someSprite's parent to joinedMapsLayer. And when joinedMapsLayer is drawn all its children will be drawn, etc.

Inside your joinedMapsLayer code you can access the child objects by accessing the children property.

Check out the documentation for CCNode (1.1 here, 2.0 here) and for CCArray (1.1 here 2.0 here).


Thanks for the info. Most of the sprites I add into arrays have a whole class included so I can edit my own custom properties. So after I make a temporary pointer off the array index I can just do tempClass.health -= 5 or access the sprite directly like tempClass.sprite.opacity = 25.

LP0 ON FIRE
Jan 25, 2006

beep boop
A couple hours ago I asked about this on StackOverflow and the Cocos2D forum, and although that's a small amount of time to get an answer, I'm eager to hear someones insight into a common problem I have.

What I have is a sprite and sprite sheet that I made properties for in a CCLayer class (JoinedMapsLayer) where my update and draw methods are. I can call a method that actually adds the sprite sheet to the layer, but I found using an instance method and class method does not work properly. Even though I point to self(JoinedMapsLayer) in my class method, it does not add the sprite sheet to it. I checked the parent object on the sprite sheet after the method is called, and it is nil.

Way more details on my StackOverflow thread:

http://stackoverflow.com/questions/10319666/cocos2d-cant-seem-to-create-child-sprites-correctly-using-class-or-instance-me

I was stuck on a similar problem all day yesterday that I called quits on for now, but since this method is simpler, I thought I'd have an easier time explaining it thoroughly, including all the details to make more apparent what I'm doing wrong.

LP0 ON FIRE
Jan 25, 2006

beep boop

Froist posted:

LP0: I'm not all that experienced in ObjC but I can't see any reason why your code isn't working I'm afraid. Like you, I'd expect that to work fine.

Well dang, it really feels like I've run out of ideas here. :( I've tried it with two different methods, and both as instance and class methods. Maybe there's something else I have in my code that's causing it but I don't know what it is.

LP0 ON FIRE
Jan 25, 2006

beep boop

Carthag posted:

Oh I get it now. LP0, put a breakpoint at the beginning of your class method and try doing po layer when it throws up the debugger. If it isn't what is expected, go to the previous method in the stacktrace in the navigator in the left side of the window, and see where it's being called from.

I think it's what is expected:

(CCLayer *) $0 = 0x004af300 <JoinedMapsLayer = 004AF300 | Tag = -1>

LP0 ON FIRE
Jan 25, 2006

beep boop

Carthag posted:

Try with a breakpoint right after [layer addChild:spriteSheet z:13]; maybe and seeing what the parent is then? You can do that with po [spriteSheet parent]. Basically if that is correct, step through the code and do the po again and see when it goes away.

With po [spriteSheet parent] right after [layer addChild:spriteSheet z:13]; I get (CCNode *) $0 = 0x00000000 <nil>.

LP0 ON FIRE
Jan 25, 2006

beep boop

Carthag posted:

What the gently caress.

Just to be sure, JoinedMapsLayer is a descendant of CCNode (through CCLayer), and you haven't overridden any of the CCNode-inherited methods?

I haven't used cocos2d but I assume CCNode's addChild: and its ilk are supposed to set the parent right?

I'm out of ideas.

I don't think I overrid any of the CCNode inherited methods.

Does the thing in bold have to do with what you just said about addChild and setting the parent? http://forums.somethingawful.com/showthread.php?threadid=3400187&userid=0&perpage=40&pagenumber=54#post402701244

I know it may not directly relate, but because I'm using a class method the parent doesn't get set?

LP0 ON FIRE
Jan 25, 2006

beep boop
Doc Block, and everyone else, thanks very much for helping.

Doc Block - I'm trying to assign the position, scale and opacity properties like you have in the code you provided, but it is giving me "Member reference base type 'CCSprite **' is not a structure or union" errors. I tried playing around with it a bit with no success and trying to understand this pointer-to-pointer stuff since I've never done it much before.

Also sorry about the NSString nonsense. That was just copied and pasted over from something that conditionally had different strings added to the file names.

Edit: I think I've got it. I need to put parentheses around *sprite and access the property like this: (*sprite).opacity = 0;

But I don't know why :confused:

Edit 2: A confirmation that it works! I'll need to study this approach a whole bunch to understand it. I'm a little slow at this stuff, and I don't think I have the mind for it, but I've been learning SLOWLY. (Also I'm not a computer science major)

So, thanks again everyone. Maybe I'll understand why I should use an instance over a class method. The reason the way I should take the class method approach is because I don't want to clutter up my class making the calls with alloc and release lines, but maybe that's not a good reason.

LP0 ON FIRE fucked around with this message at 19:00 on Apr 26, 2012

LP0 ON FIRE
Jan 25, 2006

beep boop

Bob Morales posted:

Was the iOS team forced to just pick one file system or something? Why would they pick case-insensitive and cause pain for developers?

I have no idea. It's caused me to waste a lot of time too. There's a good answer here of how to turn case-sensitivity on for iOS: http://stackoverflow.com/questions/5908931/make-iphone-simulator-case-sensitive-on-file-access

LP0 ON FIRE
Jan 25, 2006

beep boop
Some aspects of my game have been changed back and forth a few times, and now I'm revisiting a problem I'm having with making the background in open gl transparent using Cocos2D that I had three months ago. This is sort of a repost from the Cocos2D forum:

1.) I have an overlay sprite that gets added to my CCLayer at times and it's opacity is adjusted to 200 with an action. An image thats added to my UIView then shows through everything once the opacity changes when normally it's behind everything. It's as if my whole TMX tile map (or everything in openGL for that matter) has it's opacity adjusted too. This never started happening until I implemented the non-opaque background.

2.) When I hit the sleep button my iPad while the game is running, and then I turn it on again my game is running really slow until the scene is replaced.

In my delegate, if I change pixel format setting from kEAGLColorFormatRGBA8 to kEAGLColorFormatRGB565, this problem no longer occurs:
code:
EAGLView *glView = [EAGLView viewWithFrame:[window bounds]
pixelFormat:kEAGLColorFormatRGBA8
depthFormat:0];
Also another clue: If I pause then unpause CCScheduler, it fixes the slow down. (until I make my device sleep again)

But I need the transparency..

LP0 ON FIRE fucked around with this message at 20:28 on May 18, 2012

Adbot
ADBOT LOVES YOU

LP0 ON FIRE
Jan 25, 2006

beep boop

Doc Block posted:

If memory serves, ARC is only supported on iOS 4.3 and up, not 4.2.


What is an "overlay" sprite? Also, make sure you're only changing this sprite's transparency, not the layer's.

Yes, I'm only changing the sprite's transparency. The overly sprite is a tiny sprite that get's scaled to the screens size so a half-transparent texture is put over everything except for a few buttons so everything else appears darker.


Doc Block posted:

If memory serves, you're using a really old version of Cocos2D, right? Which means you probably started from the really old Cocos2D project template, right? Maybe the old template didn't have any of the multitasking methods in the app delegate.

Make sure you're pausing and unpausing the scheduler in the appropriate multitasking methods in your app delegate.

applicationWillResignActive: should call pause on the director (if the director in your old version of Cocos2D has such a method)

applicationDidBecomeActive: should call resume on the director

applicationDidEnterBackground: should call stopAnimation

applicationWillEnterForeground: should call startAnimation

applicationSignificantTimeChange: should call setNextDeltaTimeZero:YES on the director

All I'm doing differently is changing the pixel format to kEAGLColorFormatRGBA8. When I change it back to kEAGLColorFormatRGB565, the problem no longer occurs.

Doc Block posted:

This is because RGBA8 means your OpenGL ES framebuffer is 32-bit RGBA, meaning it supports the framebuffer itself being transparent. You'll note that the RGB565 pixel format has no mention of an alpha channel, hence you cannot get a transparent framebuffer when the pixel format is RGB565.

Keep in mind that your app is rendering to an OpenGL ES framebuffer object, which the GPU then composites with whatever else it's supposed to display. If you have stuff in your view hierarchy that sits underneath your OpenGL ES view, and your OGL ES framebuffer has parts that are transparent, the stuff underneath will show through.

What effect are you trying to achieve? edit: nevermind, saw that you're trying to make the background transparent. What is supposed to be showing through?

What I'm trying to show through is showing through fine. It sounds strange, but it's my own custom parallax background class made outside of Cococs2D. The reason I felt like I needed this is because I wanted preserve the parallax while Cocos2D does scene transitions which slides the last scene off the screen while a new one is dragged on. Using the Cocos2D parallax background I couldn't achieve this correctly because the new parallax background would be overlapping the old one. I tried syncing them, but it just became a mess. Performance is great with my new parallax class, and the frame rate in Cocos2D isn't hindered at all. I also have my own gradient background behind that which I can do a lot more with than the Cocos2D.


But anyway, still having problems. By the way, I'm using Cocos2D 0.99.5.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply