Concept > Chamaleonfeeder

March 2, 2010 by

So, this is my concept:

There’s a chameleon, and he’s hungry. Your job is to feed him. There’s a little complication though: he only eats flies that have the same color as his skin. And as we all know a chameleon changes color.

First you have to fix the chameleons gaze on a fly, you do this by rotating the eyes until they both look in the direction of the fly. Then, you make it shoot out its tongue by tapping. Sounds simple, right? The problem is that the chameleon will change color, so you have to lock on a fly and eat it before the chameleons skin color changes and doesn’t match the fly anymore.

Presentation app

March 2, 2010 by

The third afternoon….

in the form of an app…..

Drawing circles and lines

February 28, 2010 by

Putting images on the screen is easy with
UIImage * myImage = [UIImage imageNamed: @"justAnImage.jpg"];
UIImageView* myImageView = [[UIImageView alloc] initWithImage: myImage];

Drawing lines from code is a bit different. Although it is a bit like JAVA.
When creating an UIImageView you get a method for free:
- (void)drawRect:(CGRect)rect

and this method draws the contents the view.
You draw in a CGContext, we have already seen CGPoint, CGPointMake etc.

(Strange is the function format: suddenly “normal”: CGPointMake ( xFloat, yFloat); —no “:” to be seen….)

The drawing is updated by:
[self setNeedsDisplay];
in the code, after you either erase or add drawing shapes.
This is for removing what was drawn:
-(void) removeLines {
CGRect elementSymbolRectangle = CGRectMake(0,0,320,480);
CGContextClearRect ( context, elementSymbolRectangle );
[self setNeedsDisplay];
}

To draw lines, first set some parameters like linewidth and color: (All CG functions)
CGContextSetRGBStrokeColor (context, .9, .9, .5, .9);
CGContextSetLineWidth(context, 2.0);

Then make an CGPointArray:
CGPoint lineArray[2];
And put your two CGPoints in the array:
lineArray[0] = point1;
lineArray[1] = point2;

Then to draw you need:
CGContextAddLines ( context, lineArray, 2 );
CGContextStrokePath(context);

A bit of a problem is this context
It has to be configured at the right moment in the drawRect, and it has to be a property of the UIView.

Better see this in action:

Example of a dodecahderon and a cube which can be rotated using touch.

I added the circles to avoid the double possibility of rotating, due to the absence of any form of perspective.

Of course in OpenGL this is all much simpler. And more complex. :-)

FileIO from the app’s sandbox

February 26, 2010 by

When you want the app to store data, for instance the players name, the score etc and have it available the next time the player goes on you have to store things in the app’s sandbox.

Somehow, this is a bit complicated.

I have divided the FILEIO files in two stages: The Filio for basics like

  • clearCache (clears all files)
  • getDirectory (give the names of the existing files)
  • get an file

then I have a header and source file for converting this stuff into properties of my objects and the other way around, getting my properties in a format which is acceptable for fileio.

You have to realize that for instances arrays written to the cache can contain only objects like NSSTring, and NSNumber. More complex, homemade objects cannot be stored in an NSArray for writing to file.Actually you write a NSString to memory, and what you get out, also is a NSString. These NSStrings are then converted to arrays of NSNumbers (if needed).

This is an example where you can see the directory and have a few buttons for writing and reading two files to the sandbox of an app. The image in the background is from Grungegolf!

write a file

Reading a textfile

February 26, 2010 by

Having a text for the app, for instance the help, the best you can do is making a text file adding this to your project and reading the textfile using code. This way, a mispelled word is easily replaced without disrupting the code and the textfile is also much more readable then hard coded text in code.

This is how you read the textfile:

First get at your file:
NSString *pathNameString = @"points";
NSString *filePathString = [[NSBundle mainBundle] pathForResource:pathNameString ofType:@"txt"];

Then look if there is no mistake and read:
if (filePathString) {
NSString *myText = [NSString stringWithContentsOfFile:filePathString];
if (myText) {
NSArray *pointData = [myText componentsSeparatedByString:@","];

For numbers I use the separator “,” but anything can be used.
Now the pointData are NSStrings, so we have to get the values:
int i;
for (i=0; i< pointData.count ; i+=3 ){
float xData = (float)[[pointData objectAtIndex:i] floatValue ];

or intValue.
For a list of image names, the whitespaces must be cleaned:
NSString *imageSmallPage = [textImageObjectData objectAtIndex:i];
imageSmallPage = [imageSmallPage stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];

Sometimes, for visibility you need returns (“\n”) in your textfiles, to get these out I used:

NSString * firstBounceString = [(NSString *)[pointArrayData objectAtIndex:i] stringByReplacingOccurrencesOfString:@"\n" withString:@"" ];
int bouncePointX = (int)[firstBounceString intValue ];

All these small details handling data have to be taken care of, otherwise you’ll get in some trouble later on…

Example code: again the dodecahedron, where I have a list of lines of the dodecahedron in a textfile, the points being found by algorithm.

Sound in Xcode (short sound)

February 26, 2010 by

Sound seems to be easy, just copy from the examples:
Create a soundID
AudioServicesCreateSystemSoundID (soundFileURLRef, soundID);
and play the sound:
AudioServicesPlaySystemSound (soundID);
and wav and caf and aif is allowed, what could be more easy?

Until you hear your sound played! If it played at all. What you forget (at least I did) is this line:
The audio data in the file must be in PCM or IMA/ADPCM (IMA4) format.
What can be that stuff????
It took me a while to find out how to do that:
In the terminal window, find your soundfile and do:
macbook: contrechoc$ afconvert -f caff -d ima4 trill.wav
only this reformatting will make your soun play well.
But there is more:
The above lines of code don’t show this little detail:
what is a soundID? Well:
SystemSoundID soundID;
You make it like this:
mainBundle = CFBundleGetMainBundle ();
soundFileURLRef = CFBundleCopyResourceURL (mainBundle, CFSTR ("mySound"), CFSTR ("caf"),NULL );

But wait a minute: I know of NSString, but what is all this: CFSTR ???
And why is there no @ in front??
Ok, now you are in the apple jungle: CFSTR comes from other earlier Xcode environments, the MACOS etc….
Later on came NSString….. :-(
You have to cast this CFSTR parameter if you are carrying an NSString, which is what you want because you want to make a nice object:
(CFStringRef) soundName is of type CFSTR if soundName is of type NSString:

Knowing this you can make a nice drumpad app, with buttons carrying images of snares and base drums and sounds attached on the “action” method of these views.

Example with sounds attached to a button. The buttons are generated in a grid, and stored in an NSArray.

App-o-mator

February 17, 2010 by

The appOmator is an application for making iPhone apps.

www.appomator.com

Concept example: Bio Shoot

February 16, 2010 by

Using a photoshop file to present the start of a concept. The layers in this file make up for the different levels in a shooter game, at the moment only sparse imagery is entered.

We work in the template of a shooter.

I want to use the shooter to make choices which can be altered by a little bit of chance.

My idea was to let people create their biography in two minutes on a Iphone, even before the shooter came in. But the shooters presents a unique opportunity to give this app a little bit of a swing. At the same time the aggressiveness of the shooter is turned around. No more killing, but constructing your life!

Starting with a babytype, your next heroic deed is choosing an email address, a way to socialize, a mobile phone type and you and up choosing for a kind of car. This particular choice path makes your personality!

The choices are gender neutral.

Of course you have to shoot your favorite between different options and because of the nature of the shooter your fate can be altered. Little devils like to prevent you getting what you want.

In the end you have a list of choices and misses which are your life!

At the same time you have a list of tags which can be formed in new social groups etc etc etc….

A lot of extra features, an be added if the structure works ok, such as choosing a nickname, relate to other players with the same choices, …

Needed for the design are a nice splash, backgrounds for the different levels, better images, devil images.

Neede for the programming is a good shooter base program.

Four Hello World Examples

February 16, 2010 by

To start do it yourself, we have four basic Hello World examples.

Hello World in the NSLog, to see the debugger in action

Hello World in an ImageView, to see a first image thrown in an ImageView

Hello World in a Text box, to see the UITextView, a textfield has a large number of properties and functions, we will look at this later on.

This is the first helloworld with a widget, the name of which can be found in HelloWorld3-Info.plist

Hello World in a ULabel:not editable piece of text (not user editable), it is editable from code.

What are the differences in UITextView etc etc etc???
UILabel is not editable
UITextField is a UIControl subclass, with its own control events already defined. You need to declare a delegate for the UITextField that will follow the UITextFieldDelegate protocol
UITextView like a UITextField, except that it allows users to enter many lines of text
UISearchBar is something else, but in principle the same, not a UIControl object

see this text: www.weckstrom.com/asdf/ipod_pdf/Iphone.InAction.pdf

After these starting example we go on with several screens, using the central viewController to start subviewControllers, we have a structure of three, splashView, gameView, and gameOverView.

exampleTemplates *

After this, you could try the full push puzzle game: (currently to be found in the appstore.)

pushPuzzle *

and also the starting (first tries) of the shooters. *

*It could be that the version of Iphone  SDK does not fit these examples, then double click on the project, upper icon in project view, and choose Build, and make the debug mode like this image:

That is reset the Base SDK to Iphone Device 2.2.1 (second bold line from the top Architecture)

Assignments to get used to the views:

make a presentation app for something: your dog, your cat, your self your laptop. Use images from for instance Google images, use texts. Make some different screens, use touch to advance. Make the touch to display an image. The screens should contain more than one image and at a minimum a UILable or TextView. Experiment with colors, transparencies and fonts.

About designing apple specific icons or widgets

February 13, 2010 by

For making the special flashy icons, i found this link(s):
http://cocoawithlove.com/2009/11/creating-iphone-and-mac-icons-using.html
http://cocoawithlove.com/2009/11/creating-iphone-and-mac-icons-using_06.html

You have to remember that the icon for the game on the menu pages of the Iphone (called a widget) has to be 57 x 57 pixels. Shine will be added unless it is stated that no shine must be added.
Here another tutorial on this widget making:
http://tutorials20.com/design/design-your-iphone-widgets/

See the difference between making it (400%) and the 100% size:

But there is more inspiration: http://naldzgraphics.net/tutorials/40-photoshop-tutorials-for-creating-gadget-designs/

Really to get the flashy shiny diamond like widgets is a bit of photoshop acrobatics!

It is playing with the blending options, certainly the bevel, but also the stroke and taking some of the special effects in stroke like dissolving which come on top of the bevelled image in a layer underneath.


Follow

Get every new post delivered to your Inbox.