Friday, September 18, 2009

CGAffineTransform

Any change to a view's position, scale, or rotation can now be stored in a property of the view called transform. It's a CGAffineTransform struct, and it's a bit cryptic if you've never worked with transformation matrices before.

A transformation matrix nothing more than a two-dimensional array of numbers. Okay, perhaps I shouldn't say "just", as transformation matrices are quite powerful. They can store complex changes to the position and shape of an object, including rotating, scaling, moving, and skewing (or shearing) the view as it's drawn. This adds a little bit of programmer complexity if you want to do anything more than the absolute basics, but it opens up a world of possibilities.


To translate a view from its current position, you would pass the view's transform property here. To translate the view from its original position, you would pass in CGAffineTransformIdentity. Here is an example that would move the view five points to the right and ten points down.

theView.transform = CGAffineTransformTranslate(theView.transform, 5.0, 10.0);

Monday, September 14, 2009

interface rotation based on hand movement

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return YES;//(interfaceOrientation == UIInterfaceOrientationPortrait);
}

Tuesday, September 8, 2009

IPHone timer Event

objectmoveTimer = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(objectTimer) userInfo:nil repeats:YES];

-void(objectTimer)
{

// THis is execute Continously // since repeat is set to Yes :)
}

Monday, September 7, 2009

running Apps

in the "target " go to properties and set identifier as "com.ihexcode.first"
and add .mobileprovision and Distribution to your project

Friday, September 4, 2009

Thursday, September 3, 2009

Defining a Class

Defining a Class

Much of object-oriented programming consists of writing the code for new objects—defining new classes. In Objective-C, classes are defined in two parts:

*

An interface that declares the methods and instance variables of the class and names its superclass
*

An implementation that actually defines the class (contains the code that implements its methods)





/////////////////////////
Although the compiler doesn’t require it, the interface and implementation are usually separated into two different files. The interface file must be made available to anyone who uses the class.

A single file can declare or implement more than one class. Nevertheless, it’s customary to have a separate interface file for each class, if not also a separate implementation file. Keeping class interfaces separate better reflects their status as independent entities.

Interface and implementation files typically are named after the class. The name of the implementation file has the .m extension, indicating that it contains Objective-C source code. The interface file can be assigned any other extension. Because it’s included in other source files, the name of the interface file usually has the .h extension typical of header files. For example, the Rectangle class would be declared in Rectangle.h and defined in Rectangle.m.

Separating an object’s interface from its implementation fits well with the design of object-oriented programs. An object is a self-contained entity that can be viewed from the outside almost as a “black box.” Once you’ve determined how an object interacts with other elements in your program—that is, once you’ve declared its interface—you can freely alter its implementation without affecting any other part of the application.

/////////////
Class Interface

The declaration of a class interface begins with the compiler directive @interface and ends with the directive @end. (All Objective-C directives to the compiler begin with “@”.)

@interface ClassName : ItsSuperclass

{

instance variable declarations

}

method declarations

@end


////
The first line of the declaration presents the new class name and links it to its superclass. The superclass defines the position of the new class in the inheritance hierarchy



////
If the colon and superclass name are omitted, the new class is declared as a root class, a rival to the NSObject class.






///////////////////////
Inheritance

Class definitions are additive; each new class that you define is based on another class from which it inherits methods and instance variables. The new class simply adds to or modifies what it inherits. It doesn’t need to duplicate inherited code.

Inheritance links all classes together in a hierarchical tree with a single class at its root. When writing code that is based upon the Foundation framework, that root class is typically NSObject. Every class (except a root class) has a superclass one step nearer the root, and any class (including a root class) can be the superclass for any number of subclasses one step farther from the root. Figure 1-1 illustrates the hierarchy for a few of the classes used in the drawing program.

Some Drawing Program Classes

Friday, August 28, 2009

iphone video

skin example part 2

@ set widht, height and skin in diff class
code:
//////////////////////////////////
- (id)init {
if(self = [super init]) {
[self setBodyDef:new b2BodyDef];
[self setShapeDef:new b2PolygonDef];
[self setSize:CGSizeMake(64.0f, 64.0f)];
[self setHighlightedView:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ObstacleHighlighted.png"]] autorelease]];/// skin code by default
[self setNormalView:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ObstacleNormal.png"]] autorelease]];// skin at collision
}
return self;
}


////////////////////////
Obstacle *anObstacle = [[[Obstacle alloc] init] autorelease];
[anObstacle setPosition:CGPointMake(60.0f, 130.0f)];
[anObstacle setRotation:45.0f];
[self addActor:anObstacle];

i PHONE

self :- self is simply a hidden parameter on every method. Like any other parameter, it receives its value from the function invocation.

When you type the following:
MyClass *myObject = [[MyClass alloc] initWithString:@"someString"];


The compiler converts this into function calls that look like this:
class myClass = objc_getClass("MyClass");
SEL allocSelector = @selector(alloc);
MyClass *myObject1 = objc_msgSend(myClass, allocSelector);

SEL initSelector = @selector(initWithString:);
MyClass *myObject2 = objc_msgSend(myObject1, initSelector, @"someString");



////////////
A method needs to know what data to act upon. The self parameter tells the class the data to act upon and so is essential to object oriented programming.

This statement may seem a little strange, since you can easily implement a method without using the self parameter by name. The reality is that the compiler uses the self parameter to resolve any reference to an instance variable inside a method.

If you had a class defined like this:
@interface MyClass : NSObject
{
NSInteger value;
}
- (void)setValueToZero;
@end





///then the method:

- (void)setValueToZero
{
value = 0;
}
is converted by the compiler into:

void setValueToZero(id self, SEL _cmd)
{
self->value = 0;
}


///
So self is essential for accessing any instance variables, even if you never literally type "self".

Thursday, August 6, 2009

Sleep

body.PutToSleep()

FEEDJIT Live