After an Iphone and the Appstore, in between a Sony, now an android because of the IOIO microcontroller.
starting with Eclipse, the first android tutorial:
http://www.higherpass.com/Android/Tutorials/Writing-A-Basic-Android-Application/
and more:
http://www.higherpass.com/Android/tutorials/
but doing buttons and relative layout is not really JAVA....
for JAVA in android this link:
http://mobile.tutsplus.com/tutorials/android/java-tutorial/
After that, usually, one wants to bounce a ball:
http://www3.ntu.edu.sg/home/ehchua/programming/android/Android_2D.html
using a View with a ball inside, and showing extra possibilities.
After adding touch, all is wrapped up in an OOP fashion.
jeudi 29 décembre 2011
samedi 29 mai 2010
Some basic templates for Iphone coding
Starting up a simple Iphone app, without much coding...:-)
Step 0:
a link to a photoshop template:
http://www.teehanlax.com/blog/2009/06/18/iphone-gui-psd-30/
Step 1:
download the 3GB Xcode with simulator:
http://developer.apple.com/technology/xcode.html
Step 2:
A very basic template with 5 backgrounds is downloadable here:
ExampleTemplateView5.zip
Step 3:
Unzip the folder and look at the contents:

and all the possible other steps:-)
start with editing the pictures, 320 x 480 pixels, and save the changed pictures in the folder under the same names,
OR, change the names in the folder AND in the code, see next image:

You can also add images immediately to the xcode. Then these images have to be dragged in the space under the other images in the space at the left side of the xcode window, so under Groups and Files and Resources...see this image:

After dragging the image in the right place, you get a window asking to add the image to the destination folder: check Copy radiobutton...

Then get the simulation running by clicking the green button with the hammer, the BUILD

When changing the images do a STOP and then again a BUILD.
Other example with the splash, the middle images and the finishing page:
download a template with splash, (starting screen) some basic backgrounds, (in a slideshow) and a finishing page:
ExampleTemplateView4.zip
the bit of code you have to add to get your image on top of a background:
UIImageView *imageAdded = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"myImageName.jpg"]];
[background addSubview: imageAdded];
imageAdded.center = CGPointMake(160,150); //position of center
imageAdded.alpha = .7;//transparency
-----
the backgrounds can be found in the file GameOverViewController.m
under " - (void)touchesBegan:"
more examples and templates on www.iphoneinsandouts.wordpress.com
on this last blog you can find more templates, tricks and design links. We did a class of about ten weeks and we have two app's in the appstore as a result of this. All kind of examples can be found with source code!
Check out two results: Google on "Aaipet appstore", and "Chameleon feeder appstore"
let us all make FREE games for ALL!!!!!!!
Step 0:
a link to a photoshop template:
http://www.teehanlax.com/blog/2009/06/18/iphone-gui-psd-30/
Step 1:
download the 3GB Xcode with simulator:
http://developer.apple.com/technology/xcode.html
Step 2:
A very basic template with 5 backgrounds is downloadable here:
ExampleTemplateView5.zip
Step 3:
Unzip the folder and look at the contents:

and all the possible other steps:-)
start with editing the pictures, 320 x 480 pixels, and save the changed pictures in the folder under the same names,
OR, change the names in the folder AND in the code, see next image:

You can also add images immediately to the xcode. Then these images have to be dragged in the space under the other images in the space at the left side of the xcode window, so under Groups and Files and Resources...see this image:

After dragging the image in the right place, you get a window asking to add the image to the destination folder: check Copy radiobutton...

Then get the simulation running by clicking the green button with the hammer, the BUILD

When changing the images do a STOP and then again a BUILD.
Other example with the splash, the middle images and the finishing page:
download a template with splash, (starting screen) some basic backgrounds, (in a slideshow) and a finishing page:
ExampleTemplateView4.zip
the bit of code you have to add to get your image on top of a background:
UIImageView *imageAdded = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"myImageName.jpg"]];
[background addSubview: imageAdded];
imageAdded.center = CGPointMake(160,150); //position of center
imageAdded.alpha = .7;//transparency
-----
the backgrounds can be found in the file GameOverViewController.m
under " - (void)touchesBegan:"
more examples and templates on www.iphoneinsandouts.wordpress.com
on this last blog you can find more templates, tricks and design links. We did a class of about ten weeks and we have two app's in the appstore as a result of this. All kind of examples can be found with source code!
Check out two results: Google on "Aaipet appstore", and "Chameleon feeder appstore"
let us all make FREE games for ALL!!!!!!!
mercredi 17 février 2010
Iphone programming basics
Starting with Iphone development you have to get used to some conventions in Objective C.
First you need some output for debugging in the Debugger Console, this is done with NSLog:
( By the way, A string is preceeded by @ )
NSLog(@"read the name");//simple string output in Debugger window.
Where to find this window: here, when you are running.....: (the gdb black window button...)

Now you can see what your code is doing:
NSLog(@"look at this number %d", intNumber); //int
NSLog(@"touched loc %f %f", currentTouch.x , currentTouch.y ); //float
showing a string in NSLog:
done by using stringByAppendingString:
NSLog([@"see how the name of the player is changed in setNamePlayer :" stringByAppendingString:@"new name of player"]);
mind the function clammers: [ and ] ..... [ ... stringByAppendingString: ... ], this gives a String, because this comes from the class NSString.
simple numbers: (no pointers needed)
int, float, bool
int myInt = 9;
float myFloat = 9.123;
bool myBool = false;
Declaration: int (float, bool)
in the header:
@interface ScoreObject : NSObject {
int playingFieldNumber;
}
@property int playingFieldNumber;
in the source:
#import "ScoreObject.h"
@implementation ScoreObject
@synthesize playingFieldNumber;
Number Objects: (always pointers in Objective C)
making an Number Object (for instance needed populating NSArray or NSMutableArray
NSNumber* myNumberObject = [NSNumber numberWithInt: 99 ];
NSNumber* myNumberObject = [NSNumber numberWithFloat: 99.99 ];
getting the value back from an NSNumber Object:
int myIntValue = (int)[myNumberObject intValue];
float myFloatValue = (float)[myNumberObject floatValue];
bool myBoolValue = (bool)[myNumberObject boolValue];
using this in NSLog:
NSLog([@"look at this number %d", (int)[myNumberObject intValue]);
Declaration: objects like NSNumber, NSArray
in the header
@interface ScoreObject : NSObject {
NSMutableArray *fieldNameArray;
}
@property (nonatomic, retain) NSMutableArray *fieldNameArray;
in the source:
@implementation ScoreObject
@synthesize fieldNameArray;
Last thing about NSLog... how to get an object out?
NSLog( @"this is my object: %@", myNSNumber );
of course you do not get a int float bool, like this, but an object name.]]>
First you need some output for debugging in the Debugger Console, this is done with NSLog:
( By the way, A string is preceeded by @ )
NSLog(@"read the name");//simple string output in Debugger window.
Where to find this window: here, when you are running.....: (the gdb black window button...)

Now you can see what your code is doing:
NSLog(@"look at this number %d", intNumber); //int
NSLog(@"touched loc %f %f", currentTouch.x , currentTouch.y ); //float
showing a string in NSLog:
done by using stringByAppendingString:
NSLog([@"see how the name of the player is changed in setNamePlayer :" stringByAppendingString:@"new name of player"]);
mind the function clammers: [ and ] ..... [ ... stringByAppendingString: ... ], this gives a String, because this comes from the class NSString.
simple numbers: (no pointers needed)
int, float, bool
int myInt = 9;
float myFloat = 9.123;
bool myBool = false;
Declaration: int (float, bool)
in the header:
@interface ScoreObject : NSObject {
int playingFieldNumber;
}
@property int playingFieldNumber;
in the source:
#import "ScoreObject.h"
@implementation ScoreObject
@synthesize playingFieldNumber;
Number Objects: (always pointers in Objective C)
making an Number Object (for instance needed populating NSArray or NSMutableArray
NSNumber* myNumberObject = [NSNumber numberWithInt: 99 ];
NSNumber* myNumberObject = [NSNumber numberWithFloat: 99.99 ];
getting the value back from an NSNumber Object:
int myIntValue = (int)[myNumberObject intValue];
float myFloatValue = (float)[myNumberObject floatValue];
bool myBoolValue = (bool)[myNumberObject boolValue];
using this in NSLog:
NSLog([@"look at this number %d", (int)[myNumberObject intValue]);
Declaration: objects like NSNumber, NSArray
in the header
@interface ScoreObject : NSObject {
NSMutableArray *fieldNameArray;
}
@property (nonatomic, retain) NSMutableArray *fieldNameArray;
in the source:
@implementation ScoreObject
@synthesize fieldNameArray;
Last thing about NSLog... how to get an object out?
NSLog( @"this is my object: %@", myNSNumber );
of course you do not get a int float bool, like this, but an object name.]]>
samedi 6 février 2010
Provisioning profile blues
I was cooking up exercises now with the provisioning profiles. Just take a new clean view based project, nothing in it but the grey screen and see where you get with the different provisioning profiles, and debug release and distribution on your device.
Later on I saw someone else already having a full diner of these exercises!
http://www.codza.com/how-to-fix-iphone-code-signing-errors
Why there are two Info windows, one for the project and the other for the target, why you have to insert again a special Entitlements.plist, why you have this possibility of debugging in the Entitlements but have to uncheck it.....stopping the app running from Xcode on your device....
I hope sometimes the real apple enlightenment will shine on me...
Later on I saw someone else already having a full diner of these exercises!
http://www.codza.com/how-to-fix-iphone-code-signing-errors
Why there are two Info windows, one for the project and the other for the target, why you have to insert again a special Entitlements.plist, why you have this possibility of debugging in the Entitlements but have to uncheck it.....stopping the app running from Xcode on your device....
I hope sometimes the real apple enlightenment will shine on me...
mercredi 3 février 2010
Iphone Provisioning Profile problems links
While trying to submit my app I had to search for links explaining all the details of the weird security system of the Iphone apps, in combination with Xcode.
It really took me days and this signing is much more difficult than programming to get it right.
(Studying relativity theory is easier than getting this right, and a lot more fun!)
This is a collection of links I found useful:
http://www.24100.net/2009/02/iphone-sdk-mobile-provisioning-0xe800003a-0xe8000001/
http://www.iphonedevsdk.com/forum/iphone-sdk-development/5429-codesign-verification-nightmare.html
http://johnehartzog.com/2009/04/iphone-app-ad-hoc-gotchas/
The first blog I found with an Entitlements.pList written out is:
http://adrianhosey.blogspot.com/2009/01/iphone-development-provisioning.html
In this blog you get a picture of the contents of this file, only for me:
debugging has to be allowed!!! (in debugging) Other tell to uncheck this.(for release)

In release (device) the app is loaded to my device, but not started, I have to start it myself.
Then I discovered there were two files with seperate properties: (called Info)
double click on Project to get the Project Properties: Project Info
double click on the app icon under Target to get the Target properties: Target Info
These files are practically the same, but the Code Signing Entitlements is not taken over!!!
So for me one was at still at dist.plist the other on Entitlements.plist, giving an error!!!!
So we should set SIX files the right way.... (debug release distribution, for simulator and for device.....)
Who has cooked this system up?
It must have been the Tetris God, messing up!
(see him here: http://www.youtube.com/watch?v=Alw5hs0chj0)
It really took me days and this signing is much more difficult than programming to get it right.
(Studying relativity theory is easier than getting this right, and a lot more fun!)
This is a collection of links I found useful:
http://www.24100.net/2009/02/iphone-sdk-mobile-provisioning-0xe800003a-0xe8000001/
http://www.iphonedevsdk.com/forum/iphone-sdk-development/5429-codesign-verification-nightmare.html
http://johnehartzog.com/2009/04/iphone-app-ad-hoc-gotchas/
The first blog I found with an Entitlements.pList written out is:
http://adrianhosey.blogspot.com/2009/01/iphone-development-provisioning.html
In this blog you get a picture of the contents of this file, only for me:
debugging has to be allowed!!! (in debugging) Other tell to uncheck this.(for release)

In release (device) the app is loaded to my device, but not started, I have to start it myself.
Then I discovered there were two files with seperate properties: (called Info)
double click on Project to get the Project Properties: Project Info
double click on the app icon under Target to get the Target properties: Target Info
These files are practically the same, but the Code Signing Entitlements is not taken over!!!
So for me one was at still at dist.plist the other on Entitlements.plist, giving an error!!!!
So we should set SIX files the right way.... (debug release distribution, for simulator and for device.....)
Who has cooked this system up?
It must have been the Tetris God, messing up!
(see him here: http://www.youtube.com/watch?v=Alw5hs0chj0)
jeudi 24 décembre 2009
Debugging a double free malloc error
When making an instance you have to free it again with release. But there is also for some familiar things like CGArray an auto release.
I had an error in the Debugging Window telling me there was a double release....
malloc: *** error for object 0x1346f90: double free
*** set a breakpoint in malloc_error_break to debug
where to put what breakpoint?
in gdb? well somehow this didn't work for me.
The problem is of course the object is released later on, not stopping at the line which caused the problem....
these links helped me setting the environmental variables needed to debug:
http://lists.apple.com/archives/Xcode-users/2008/Apr/msg00160.html
http://www.cocoadev.com/index.pl?DebuggingAutorelease
http://www.cocoadev.com/index.pl?MallocStackLogging
http://www.cocoadev.com/index.pl?NSZombieEnabled
http://www.cocoadev.com/index.pl?DebuggingTechniques
after setting the environmental variables given in the link I got this error:
*** -[CFArray release]: message sent to deallocated instance 0x135e0a0
which didn't tell me anything new, the instance number I could not trace...
the debugger told me this:
malloc: stack logs being written into /tmp/stack-logs.373.Grungegolf.KT6xux
but where is this file situated?
this command didn't help because the pin number (in this example 3939) from this example is not in my gdb error
gdb: t a a bt
in the end I searched for all the release commands I have given with the only clue that is must be an Array, and I found the culprit...
trying to understand:
I loaded a textfile:
NSString *myText = [NSString stringWithContentsOfFile:whateverFilePathString];
I used this to load my game fields, being all in the textFile, a String
so seperate the fields:
NSArray *allData = [myText componentsSeparatedByString:@"***"];
with the separator "***"
then taking element 3 which contained the bouncers...
NSArray *bouncerData = [[allData objectAtIndex:2] componentsSeparatedByString:@","];
putting the bouncer data, making them numbers in another array of objects...
I released the bouncerData (wrong!)
I suppose this bouncerData array is released with the allData array, which is also released automatically....
I had an error in the Debugging Window telling me there was a double release....
malloc: *** error for object 0x1346f90: double free
*** set a breakpoint in malloc_error_break to debug
where to put what breakpoint?
in gdb? well somehow this didn't work for me.
The problem is of course the object is released later on, not stopping at the line which caused the problem....
these links helped me setting the environmental variables needed to debug:
http://lists.apple.com/archives/Xcode-users/2008/Apr/msg00160.html
http://www.cocoadev.com/index.pl?DebuggingAutorelease
http://www.cocoadev.com/index.pl?MallocStackLogging
http://www.cocoadev.com/index.pl?NSZombieEnabled
http://www.cocoadev.com/index.pl?DebuggingTechniques
after setting the environmental variables given in the link I got this error:
*** -[CFArray release]: message sent to deallocated instance 0x135e0a0
which didn't tell me anything new, the instance number I could not trace...
the debugger told me this:
malloc: stack logs being written into /tmp/stack-logs.373.Grungegolf.KT6xux
but where is this file situated?
this command didn't help because the pin number (in this example 3939) from this example is not in my gdb error
shell malloc_history 3939 0xa4e10this didn't help either:
gdb: t a a bt
in the end I searched for all the release commands I have given with the only clue that is must be an Array, and I found the culprit...
trying to understand:
I loaded a textfile:
NSString *myText = [NSString stringWithContentsOfFile:whateverFilePathString];
I used this to load my game fields, being all in the textFile, a String
so seperate the fields:
NSArray *allData = [myText componentsSeparatedByString:@"***"];
with the separator "***"
then taking element 3 which contained the bouncers...
NSArray *bouncerData = [[allData objectAtIndex:2] componentsSeparatedByString:@","];
putting the bouncer data, making them numbers in another array of objects...
I released the bouncerData (wrong!)
I suppose this bouncerData array is released with the allData array, which is also released automatically....
Libellés :
DebuggingAutorelease,
double free,
malloc,
release
mardi 27 octobre 2009
NSArray features
We had an NSArray of objects of the type UIImageView.
the array was retained being a property etc
initialize like this:
testBall2Array = [NSMutableArray arrayWithObjects:
[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],
[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],
[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],
[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],
[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],
nil];
We succeeded in putting the views on screen in the same method but apparently in another method we got a bad access error when doing something with an element of this array.
The elements were not retained, but how to retain them?
This is one of the niceties of Xcode! :-(((
The answer is found here:
http://stackoverflow.com/questions/519467/iphone-getting-the-uiimageview-back-from-nsarray
you have to initialize with a different method:
the array was retained being a property etc
initialize like this:
testBall2Array = [NSMutableArray arrayWithObjects:
[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],
[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],
[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],
[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],
[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],
nil];
We succeeded in putting the views on screen in the same method but apparently in another method we got a bad access error when doing something with an element of this array.
The elements were not retained, but how to retain them?
This is one of the niceties of Xcode! :-(((
The answer is found here:
http://stackoverflow.com/questions/519467/iphone-getting-the-uiimageview-back-from-nsarray
you have to initialize with a different method:
initWithObjects
instead ofarrayWithObjects
the first retains the objects the second doesn't......
well this is the way you spent your time doing Xcode....
Inscription à :
Messages (Atom)

