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
Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
I have seen people claim that AirPlay is an open protocol and I've also seen people claim there are apps out there that can stream pictures to AppleTV.

What I haven't found is an actual specification for the AirPlay protocol. Does anyone know if it is documented anywhere? I'd like to send pictures specifically but as far as I know that isn't supported in the SDK.

Adbot
ADBOT LOVES YOU

Doc Block
Apr 15, 2003
Fun Shoe
I don't think it's publicly documented by Apple, but IIRC some dudes reverse engineered it.

LP0 ON FIRE
Jan 25, 2006

beep boop

pokeyman posted:

I'm sure you've had a look at the Key-Value Coding Programming Guide. Specifically, I mean the part where it discusses resolving key paths to values. If a method with the same name as the key is implemented, it gets called and its return value is the value for the key path. Otherwise, if an instance variable with the same name exists, its value is returned.

So if you want [layer valueForKey:@"collidableCoordinate"] to give you tile coordinates, implement -collidableCoordinate on the class of layer. If it's not a class you control, implement it in a category (with a prefix, like -nog_collidableCoordinate). Also keep in mind that the return value from -valueForKey: will be boxed (i.e. an NSValue or subclass as opposed to an int/float/struct), so you'll likely need to unbox it first.

Thanks pokeyman. I still haven't got to this stage yet because I gave up on subclassing my sprite methods for a bit to make progress in other places, but this will help so much and makes a ton of sense to use it.



I have yet another problem if anyone wants to help. Right now I can't get it to run on my device without immediately crashing. It worked with a much older version. I made a question on Stack Overflow if anyone wants to see more details: http://stackoverflow.com/questions/6049827/cocos2d-crashing-on-iphone-immediately-but-not-in-simulator

But basically on the simulator, I get a message in the console "CCSpriteFrameCache: Trying to use file 'heroTestSheet.png' as texture" but everything seems to work fine. Putting it on to a device just gives me a white screen until it crashes and the console gives me a report. I saw this a lot of time has to do with filenames in my resources verses my code have different capital letters, but I've looked over all of them and even revealed them in the Finder to make sure. :confused:

Starting to think it has to do with how I'm coding the sprite class and I did something wrong.

LP0 ON FIRE fucked around with this message at 18:36 on May 19, 2011

Doc Block
Apr 15, 2003
Fun Shoe
In the Cocos2D debug output it says that it couldn't find one of the frames you specified. Open the plist in a plist editor and see what is actually in there.

Also, what are you using to generate the sprite atlases in the first place?

LP0 ON FIRE
Jan 25, 2006

beep boop

Doc Block posted:

In the Cocos2D debug output it says that it couldn't find one of the frames you specified. Open the plist in a plist editor and see what is actually in there.

Also, what are you using to generate the sprite atlases in the first place?

In the plist there is heroFrame1.png and heroFrame2.png. Which means it's using the plist to make those from the texture heroTestSheet.png, right?

Here's a shot:


I'm using Zwoptex.

edit: I just wanted to add that I also put this in my zone class that adds the map and the sprite in init:

hero = [[HeroClass alloc] init];
[self addChild:hero.heroSpriteSheet];

I didn't do addChild to anything else for the hero class which I hope is okay and makes sense.

LP0 ON FIRE fucked around with this message at 19:37 on May 19, 2011

klem_johansen
Jul 11, 2002

[be my e-friend]
I'm searching around my build settings and info plists for what I can do to change the default language of my app in the store. It's a Chinese app offered only in the Chinese store. It's not really a localized app, so I haven't messed around with that. I have a suspicion that changing the Localization native development region, but I want to be sure before uploading a new binary.

Would setting it to Taiwan make any difference? Or could it be that it's an error on Apple's side? Someone mentioned that it could be a matter for iTunesConnect support.

go play outside Skyler
Nov 7, 2005


klem_johansen posted:

I'm searching around my build settings and info plists for what I can do to change the default language of my app in the store. It's a Chinese app offered only in the Chinese store. It's not really a localized app, so I haven't messed around with that. I have a suspicion that changing the Localization native development region, but I want to be sure before uploading a new binary.

Would setting it to Taiwan make any difference? Or could it be that it's an error on Apple's side? Someone mentioned that it could be a matter for iTunesConnect support.

This is a shot in the dark but... If you can change the country to Taiwan, can't you change it to China? If China's not there, try People's Republic of China as that is the official name of the country.

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

NOG posted:

But basically on the simulator, I get a message in the console "CCSpriteFrameCache: Trying to use file 'heroTestSheet.png' as texture" but everything seems to work fine. Putting it on to a device just gives me a white screen until it crashes and the console gives me a report. I saw this a lot of time has to do with filenames in my resources verses my code have different capital letters, but I've looked over all of them and even revealed them in the Finder to make sure. :confused:
Stick a breakpoint on the line which calls [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"heroTestSheet.plist"];

Then run your App on the device and step into the code line by line verifying that everything is working as you'd expect until you find the point at which Cocos is giving up on loading/creating the texture. That'll give you (and us) a big hint as to what's failing.

Cocos isn't a particularly fat framework and is pretty well structured & commented so you shouldn't be afraid to delve into its code to discover just what it's doing when expectations are being confounded.

klem_johansen
Jul 11, 2002

[be my e-friend]

Sir Davey posted:

This is a shot in the dark but... If you can change the country to Taiwan, can't you change it to China? If China's not there, try People's Republic of China as that is the official name of the country.

Everything I read tells me that I need to add .lproj localization folders but this isn't a localized app. It's a single language but somehow the app store won't say that it's Chinese.

Doc Block
Apr 15, 2003
Fun Shoe
Maybe an app without any localization info is considered "localized" to English. So you most likely *do* need to add a Chinese localization, but make it the only one.

klem_johansen
Jul 11, 2002

[be my e-friend]
Thanks! I think you're right.

I recently did a Dutch one and it's listed as dutch in the store without me having to do a thing. I think Chinese might be an odd case since the character encoding might be different.

functional
Feb 12, 2008

iOS disk: can someone briefly summarize what the correct options are for writing to disk on iOS? I have a couple of settings I need to store, and potentially some other dictionary or array-like data. The options have changed over time, and I'm trying to avoid reading 100 meandering blog posts to figure out what could be succinctly stated in a a few lines.

functional fucked around with this message at 23:56 on May 20, 2011

Doc Block
Apr 15, 2003
Fun Shoe
AFAIK you still just write to Documents, and it'll get backed up when the user syncs their device with iTunes.

The actual method can be anything, you can just write binary blobs with fwrite() if you want. You could save to XML, an SQLite database, CoreData, or whatever, it just depends on your data.

functional
Feb 12, 2008

Thanks, Doc Block, exactly what I was looking for.

Doc Block
Apr 15, 2003
Fun Shoe
A lot of people forget that all the Unix stuff is still in there, including all the Unix file stuff.

John Carmack wrote up an interesting blog post about using relatively low-level Unix stuff like memory mapped files in Rage HD.

Doc Block fucked around with this message at 00:53 on May 21, 2011

Small White Dragon
Nov 23, 2007

No relation.

Doc Block posted:

A lot of people forget that all the Unix stuff is still in there, including all the Unix file stuff.

John Carmack wrote up an interesting blog post about using relatively low-level Unix stuff like memory mapped files in Rage HD.
NSData will memory-map files for you, if you let it.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
For simple stuff like settings you can use NSUserDefaults.

It is also trivial to serialize plists.

LP0 ON FIRE
Jan 25, 2006

beep boop

ynohtna posted:

Stick a breakpoint on the line which calls [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"heroTestSheet.plist"];

Then run your App on the device and step into the code line by line verifying that everything is working as you'd expect until you find the point at which Cocos is giving up on loading/creating the texture. That'll give you (and us) a big hint as to what's failing.

Cocos isn't a particularly fat framework and is pretty well structured & commented so you shouldn't be afraid to delve into its code to discover just what it's doing when expectations are being confounded.

Thanks for the suggestion. So it stopped on CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage:texturePath]; in the addSpriteFramesWithFile:(NSString*)plist method in CCSpriteFrameCache.m. Is a .png a valid texture? Still don't get what's wrong, but I guess it can't get the correct path or something?

Doc Block
Apr 15, 2003
Fun Shoe
Yes, a PNG is a valid texture. Dunno if Cocos2D can deal with color indexed PNGs or progressive PNGs, though.

For whatever reason it can't load the heroTestSheet.png. I'm not really familiar with a lot of the new Cocos2D stuff, try asking the Cocos2D forums.

LP0 ON FIRE
Jan 25, 2006

beep boop
Figured it out.. it's so stupid, but it was just the heroTestSheet.png it was trying to use was somehow invalid. I exported in an older photoshop, but I'm not really positive what settings it had. I exported it again from a newer photoshop without any color mange settings, and now it works fine! I stepped through the Cocos2D methods when I was debugging, and getting the message "CCSpriteFrameCache: Trying to use file 'heroTestSheet.png' as texture" in the console is totally fine, it's just saying it's doing something different to assign the filename.

Doc Block
Apr 15, 2003
Fun Shoe
Wait... why are you putting together a sprite sheet in Zwoptex and then messing with it in Photoshop? Glad you figured it out at least.

Small White Dragon
Nov 23, 2007

No relation.
Had a discussion with another developer and now I'm curious.

Anyone here do programmatic layouts? If so, where do you your cleanup for loadView?

Sewer Adventure
Aug 25, 2004

Small White Dragon posted:

Had a discussion with another developer and now I'm curious.

Anyone here do programmatic layouts? If so, where do you your cleanup for loadView?

Yes, what do you mean by cleanup? nil your subview properties in viewDidUnload and in dealloc.

wellwhoopdedooo
Nov 23, 2007

Pound Trooper!
[tell] me about Core Data.

As someone who's very comfortable in both SQL and C, and who started to miss things you can do in SQL in the first 15 minutes of modeling my data, why should I use it anyway? The advice to use it seems very emphatic.

LP0 ON FIRE
Jan 25, 2006

beep boop

Doc Block posted:

Wait... why are you putting together a sprite sheet in Zwoptex and then messing with it in Photoshop? Glad you figured it out at least.

The sprite sheet was already one graphic. I just want the plist. This way I can still go back into photoshop and make any changes I need. That's okay, right? Maybe that doesn't make sense, I don't know. Probably doesn't, but I'll learn.

Anyway, I'm trying to make this run fast on older iPhone models, 3G and prior. It runs at a full 60 fps on iPhone 4, but around 30 on 3G. I've seen an automatic way to ignore tile rendering outside of a screen area, but I can't find the page that showed how to do this. Does anyone know what I'm referring to?

OHIO
Aug 15, 2005

touchin' algebra

OHIO posted:

Some patent troll is asking for licenses on people using in-app purchases: http://cultofmac.com/ios-devs-under-fire-by-patent-troll-for-offering-in-app-purchases/94916

I hope Apple helps him out, I don't know what the gently caress I'd do.

Apple is not going to stand for the in-app-purchases patent troll! http://www.macworld.com/article/160031/2011/05/apple_legal_lodsys_letter_text.html

Doc Block
Apr 15, 2003
Fun Shoe

NOG posted:

The sprite sheet was already one graphic. I just want the plist. This way I can still go back into photoshop and make any changes I need. That's okay, right? Maybe that doesn't make sense, I don't know. Probably doesn't, but I'll learn.

Anyway, I'm trying to make this run fast on older iPhone models, 3G and prior. It runs at a full 60 fps on iPhone 4, but around 30 on 3G. I've seen an automatic way to ignore tile rendering outside of a screen area, but I can't find the page that showed how to do this. Does anyone know what I'm referring to?

I don't know if Zwoptex does, but TextureTool can be called from the command line, and you can make a custom build step in Xcode that will call TextureTool to assemble the sprite sheet as part of the app's build process. I don't recommend opening up the sprite sheet and modifying it directly.

Also, keep in mind that pre-3GS devices have a max texture size of 1024x1024 and only have 128MB RAM. They also make up a pretty small segment of the iOS market.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

wellwhoopdedooo posted:

[tell] me about Core Data.

As someone who's very comfortable in both SQL and C, and who started to miss things you can do in SQL in the first 15 minutes of modeling my data, why should I use it anyway? The advice to use it seems very emphatic.

For me, Core Data answers the question "what can I use to persist my model objects, assuming I don't give a poo poo at all about how it's done?"

In theory, there's basically zero friction when using Core Data. Need to fetch a collection of related objects? Just use them and Core Data will fetch them on demand. Need to save everything? Just send -save. Need a new scratchpad to make some objects and relationships? Fire up a new context and save it (or ditch it) when you're done. Core Data is fast as hell, there's almost nothing you can do faster if you do it manually. Oh, and mogenerator is fantastic at writing cruft-removing code for you.

In practice, I find Core Data to be quite painful. Maybe it's because I get mad at it and swear off using it for months, thereby forgetting everything about it in the intervening period. But I find its promise of free undo management consistently broken (the actions sent to the undo manager were whacked). Handling validation errors at save time really sucks, especially on the save just before the app quits. And I typically have to write some code over top of Core Data to do away with some of its verbosity (check the docs for, say, fetching all the objects of one kind). And NSFetchedResultsController sucks.

Overall, if you like accessing databases in C, you might find Core Data just gets in your way. On the other hand, if you're of the opinion that less code means less time wasted debugging and supporting, Core Data can replace huge chunks of your code. Just don't believe all the hype around Core Data! You still need to write code, undo isn't free, etc.

LP0 ON FIRE
Jan 25, 2006

beep boop

Doc Block posted:

I don't know if Zwoptex does, but TextureTool can be called from the command line, and you can make a custom build step in Xcode that will call TextureTool to assemble the sprite sheet as part of the app's build process. I don't recommend opening up the sprite sheet and modifying it directly.

Also, keep in mind that pre-3GS devices have a max texture size of 1024x1024 and only have 128MB RAM. They also make up a pretty small segment of the iOS market.

Thanks for the info. So a work flow of making a sprite sheet with an automated plist, is usually making separate files for each sprite, and then assembling them together in sprite sheet tool like Zwoptex to make the sheet? The only thing that catches me off guard about this is now someone is making graphics in a bunch of separate files, which seems disorganized and confusing. Maybe I'm just crazy, but is this the way it's usually done? I'll definitely look into TextureTool TexturePacker since a lot of people are using that.

Right now all I'm using is a test player sprite sheet thats 128x64 and split up into two 64x64's, and a texture atlas for the tiles that's only 320x320, that's split up into 16x16's. My background is just a gradient background rendered from code. I should have mentioned, but I'm also testing this on iPad 1 and 2 which are displaying a lot more tiles. On the iPad 1, it runs 30 fps, much like the iPhone 3G. On the iPad 2, it runs 60 fps, much like the iPhone 4.

It's good to know there's very little market for pre 3GS devices, but I'm curious if there was something I could do to give a significant boost in performance, or if that's what usually happens to pre-3GS devices and Cocos2D.

LP0 ON FIRE fucked around with this message at 06:22 on May 24, 2011

Doc Block
Apr 15, 2003
Fun Shoe
Yes, AFAIK most people work on each sprite as a separate file. There are a few advantages to this, a big one being that you can work on the sprite on its own, then let Zwoptex or TextureTool optimize how it all goes onto the sprite sheet. Different frames can be different sizes, etc.

Also, with TextureTool at least, it will show you how the sprite sheet would look if reduced to RGBA444 or RGB565 or whatever, and can even go ahead and do the quantization when it saves the sprite sheet. So you would at least want to have your "original" sprite sheet that you made in Photoshop and then have TextureTool output a "final" sprite sheet that's been saved in a device-friendly format.

Which leads me to my next point, optimization. One of the ways you can optimize your game to help it run better on older devices is reduce your texture size. Cocos2D can convert your 32-bit PNGs down from 8 bits per channel (RGBA8888) to 4 bits per channel (RGBA4444), which reduces the texture size in memory and also increases performance since the GPU will be able to fit more of the texture in it's cache. It can also convert to RGB565 for textures that don't need an alpha channel (like backgrounds), and other formats as well if memory serves.

You may also want to look at using PVRTC for some of your textures. This is one place where having your sprites all be in separate files comes in handy, because you can put the sprites that still look acceptable in PVRTC one one sprite sheet and the rest on another.

Another optimization is to use a 16-bit framebuffer instead of a 32-bit one, if it doesn't cause too much color banding. I don't remember if this is the default for Cocos2D or not.

Also, as to your 320x320 texture atlas for tiles: NO! That texture is going to get bumped up to 512x512, which is the nearest power-of-two size that will fit the whole thing.

Lastly, read Cocos2D's best practices guide.

Doc Block
Apr 15, 2003
Fun Shoe
:ughh: I'm a moron, been saying TextureTool when I meant TexturePacker.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

pokeyman posted:

Stuff

I second this motion. The problem with CoreData is the same problem I have with the whole framework as compared to something like C#... I end up writing the same boilerplate over and over (and so does everyone else).

Everyone ends up writing unique ID generation stuff. Everyone rewrites pulling all of the same object out. Everyone rolls their own undo. No generics or custom typing of properties so everyone has a different solution for dealing with the fact that all your bools, floats, and ints end up as NSNumbers.

Still, I do use it.

NoDamage
Dec 2, 2000

wellwhoopdedooo posted:

[tell] me about Core Data.

As someone who's very comfortable in both SQL and C, and who started to miss things you can do in SQL in the first 15 minutes of modeling my data, why should I use it anyway? The advice to use it seems very emphatic.
The main benefit of using Core Data on iOS is it integrates (relatively) nicely with the UITableView. If you have a large data set, using NSFetchedResultsController and a UITableView takes care of lazy loading your data objects as they scroll into view, and unloading them as they scroll out of view, so you get nice behind the scenes performance optimizations to help ensure everything runs quickly and smoothly on the device and you don't run out of memory if you need to display several thousand rows of data at once.

The price you pay, of course, is that Core Data is a tremendously overengineered framework and a pain in the rear end to use. Particularly, doing database migrations are a *bitch* (if anyone has difficulties with this in their app, feel free to PM me).

Is it worth it? If you're doing a database driven iOS app, I would say yes, since there's a lot of useful stuff you get for free. But there is definitely a learning curve to it.

Asnorban
Jun 13, 2003

Professor Gavelsmoke


I was just tasked with writing an image exporter / upload plugin for Aperture and iPhoto at my job. While I can find plenty on Aperture, I can not find anything remotely recent about where to begin on writing a plug-in for iPhoto or if there is an API available for it. Perhaps I am missing something and don't know where to look for documentation, so any help would be appreciated.

fankey
Aug 31, 2001

I'm trying to create a write-only property. If I just define the set* method like this
code:
@interface Foo
{
}
-(void)setBar:(NSString*)str;
@end

@implementation Foo
-(void)setBar:(NSString*)str
{
  // do something here
}
@end
and then attempt to access it
code:
Foo* someFoo;
someFoo.Bar = @"this is a test";
The complier complains that 'Request for member 'Bar' is something not a structure or union'. If I add an accessor function it works fine.
code:
@interface Foo
{
}
-(NSString*)bar;
-(void)setBar:(NSString*)str;
@end

@implementation Foo
-(NSString*)bar
{
  return @"asdf";
}
-(void)setBar:(NSString*)str
{
  // do something here
}
@end
I'd rather not have a bunch of dummy accessor functions that return garbage since I'm not storing the state - it gets passed on to another layer. Is there a way to implement write-only properties?

Doc Block
Apr 15, 2003
Fun Shoe
Why are you trying to use properties for this? Just call [foo setBar:@"YOURMOM.LAFFO"];

A property is supposed to look (to the caller) like an instance variable, and a write-only variable doesn't make sense.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

fankey posted:

I'm trying to create a write-only property. If I just define the set* method like this

and then attempt to access it
code:
Foo* someFoo;
someFoo.Bar = @"this is a test";
The complier complains that 'Request for member 'Bar' is something not a structure or union'. If I add an accessor function it works fine.

I'd rather not have a bunch of dummy accessor functions that return garbage since I'm not storing the state - it gets passed on to another layer. Is there a way to implement write-only properties?

No there is not. It only supports readwrite and readonly @property declarations, though the usefulness of a write only property is debatable, since your code should be using the getter inside the class anyway.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

fankey posted:

I'd rather not have a bunch of dummy accessor functions that return garbage since I'm not storing the state - it gets passed on to another layer.

A setter is not what you want if you're literally doing nothing but passing along the message. Just make it a method.

Maybe you could post the actual problem you're trying to solve and we can help organize it for you? (Note: code is better than a description.)

fankey
Aug 31, 2001

Apparently I kicked the write-only property hornets nest. I was mainly curious as to why it didn't work. Is it an intentional design choice in ObjC to fail so one cannot create write-only properties or is it a side effect of how properties are implemented?

The Property Declaration docs state that you must have both a setter and getter. Since I wasn't declaring the property explicitly I was surprised I got an error.

Adbot
ADBOT LOVES YOU

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Without getting into write-only, you don't capitalize the property when setting it.

-(NSString *)bar;
-(void)setBar:(NSString*)str;

means you use

foo.bar = @"whatever"; //not foo.Bar = ...

It probably still won't work without a getter though.

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