Thursday, April 22, 2010

In the MVC design pattern, the model layer consists of objects that represent the data your application manages. The objects in this layer should be organized in the way that makes the most sense for the data. External interactions with model objects occur through a well-defined set of interfaces, whose job is to ensure the integrity of the underlying data at all times.

The view layer defines the presentation format and appearance of the application. This layer consists of your application’s windows, views, and controls. The views can be standard system views or custom views you create. You configure these views to display the data from your model objects in an appropriate way. In addition, your view objects need to generate notifications in response to events and user interactions with that data.

The controller layer acts as the bridge between the model and view layers. It receives the notifications generated by the view layer and uses them to make the corresponding changes in the data model. Similarly, if the data in the data layer changes for other reasons (perhaps because of some internal computation loop), it notifies an appropriate controller object, which then updates the views.


EXP--

View is just a GUI so when user interact with GUI (controller) and modify data indirectly(which is a model)

MVC

In the MVC design pattern, the model layer consists of objects that represent the data your application manages. The objects in this layer should be organized in the way that makes the most sense for the data. External interactions with model objects occur through a well-defined set of interfaces, whose job is to ensure the integrity of the underlying data at all times.

The view layer defines the presentation format and appearance of the application. This layer consists of your application’s windows, views, and controls. The views can be standard system views or custom views you create. You configure these views to display the data from your model objects in an appropriate way. In addition, your view objects need to generate notifications in response to events and user interactions with that data.

The controller layer acts as the bridge between the model and view layers. It receives the notifications generated by the view layer and uses them to make the corresponding changes in the data model. Similarly, if the data in the data layer changes for other reasons (perhaps because of some internal computation loop), it notifies an appropriate controller object, which then updates the views.

Wednesday, April 21, 2010

Revolute joint

public var rev1:b2RevoluteJoint;
var bodyDef2:b2BodyDef;
var boxDef2:b2PolygonDef;

bodyDef2 = new b2BodyDef();
bodyDef2.position.Set(26, 12.5);
//bodyDef2.angle = -.5;


boxDef2 = new b2PolygonDef();
boxDef2.SetAsBox(3, .1);//7
boxDef2.friction = .1;
boxDef2.density = 12.1;
/*
*/
body2 = m_world.CreateBody(bodyDef2);
body2.CreateShape(boxDef2);
body2.SetMassFromShapes();


/////////////// body 20

var bodyDef20:b2BodyDef;
var boxDef20:b2PolygonDef;

bodyDef20 = new b2BodyDef();
bodyDef20.position.Set(23, 12.5);
//bodyDef2.angle = -.5;


boxDef20 = new b2PolygonDef();
boxDef20.SetAsBox(.5, .1);//7
boxDef20.friction = .1;
boxDef20.density = 0;
/*
*/
body20 = m_world.CreateBody(bodyDef20);
body20.CreateShape(boxDef20);
body20.SetMassFromShapes();

///////////////////


var rjdDef:b2RevoluteJointDef = new b2RevoluteJointDef();
rjdDef.Initialize(body2, body20, body20.GetWorldCenter() );

rjdDef.enableLimit=true;
// rjdDef.maxMotorTorque=16600.0;
//rjdDef.motorSpeed=500.0;

rjdDef.enableMotor=true;
rjdDef.lowerAngle=-0.18*3.14
rjdDef. upperAngle=0.25*3.14
rev1 = m_world.CreateJoint(rjdDef) as b2RevoluteJoint;

/////// center is static and other is dynamic .. and you can play with dynamic///
somthing like this


body2.SetAngularVelocity(ang);

Wednesday, April 14, 2010

cocos2d updates implementation

http://code.google.com/p/cocos2d-iphone/source/browse/tags/release-0.99.0/README#87

Thursday, April 8, 2010

Particle effect Implementation

CCParticleSystem *emitter = [CCParticleExplosion node];

emitter = [[CCParticleMeteor alloc] init];
emitter = [[CCParticleFire alloc] init];
emitter.texture = [[CCTextureCache sharedTextureCache] addImage:@"fire.png"];
emitter.position = ccp(location.x,location.y);
emitter.life = 0.2f;
emitter.duration = 0.3f;
emitter.lifeVar = 0.3f;


[self addChild:emitter];

Wednesday, March 10, 2010

Animate sprite

sheet99 = [CCSpriteSheet spriteSheetWithFile:@"fan_l1l2_left.png" capacity:12];
[self addChild:sheet99 z:4 tag:kTagSpriteSheet];
sprite99 = [sheet99 createSpriteWithRect:CGRectMake(0,0,300,400)];//32 * idx,32 * idy,32,32
sprite99.position=ccp(4,14);
[sheet99 addChild:sprite99 z:7];




CCAnimation *animation = [CCAnimation animationWithName:@"dance" delay:.1f ];

[animation addFrameWithTexture:sheet99.texture rect:CGRectMake(-121,0,242,400)];//-121
[animation addFrameWithTexture:sheet99.texture rect:CGRectMake(0, 0, 242,400)];//0,0
id action = [CCAnimate actionWithAnimation:animation];
// Run the animation
//id repeatAction = [CCRepeat actionWithAction:action times:100];

// To repeat forever, use this
id repeatAction = [CCRepeatForever actionWithAction:action];

[sprite99 runAction:repeatAction];

body and updation

b2BodyDef bodyDef9c8;
bodyDef9c8.type =b2_staticBody;

bodyDef9c8.position.Set(9,9);//
//bodyDef9c8.angle=-58;
//bodyDef.userData = sprite;
b2Body* body9c8;
//= world->CreateBody(&groundBodyDef5);
body9c8 = world->CreateBody(&bodyDef9c8);

// Define another box shape for our dynamic body.
b2PolygonShape dynamicBox9c8;
dynamicBox9c8.SetAsBox(1.7f, .1f);//These are mid points for our 1m box

// Define the dynamic body fixture.
b2FixtureDef fixture9c8;
//fixture99.userData = @"Box";

fixture9c8.shape = &dynamicBox9c8;
fixture9c8.density = 0;
fixture9c8.friction = 0.3f;
fixture9c8.restitution=1.1f;
body9c8->CreateFixture(&fixture9c8);



#####################
update
###################
body0->SetTransform (b2Vec2(8,12),0);//target replaced by setXform

Friday, February 19, 2010

Tuesday, February 9, 2010

stack in objc

for (float32 x =0.0f; x<300.0f; x=x+1.0f) {
float32 y=1.0f;
// Define the static body.
//Set up a 1m squared box in the physics world
b2BodyDef bodyDef;
bodyDef.type = b2_staticBody;

bodyDef.position.Set(x, y);
b2Body *body = world->CreateBody(&bodyDef);

// Define another box shape for our static body.
b2PolygonShape staticBox;
staticBox.SetAsBox(.5f, .5f);//These are mid points for our 1m box

// Define the static body fixture.
b2FixtureDef fixtureDef;
fixtureDef.shape = &staticBox;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.3f;
body->CreateFixture(&fixtureDef);
}

FEEDJIT Live