recalling old memories
http://www.cs.ucr.edu/~pdiloren/C++_Pointers
Monday, March 29, 2010
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];
[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
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
Subscribe to:
Posts (Atom)