本文整理汇总了C++中cpShapeSetFriction函数的典型用法代码示例。如果您正苦于以下问题:C++ cpShapeSetFriction函数的具体用法?C++ cpShapeSetFriction怎么用?C++ cpShapeSetFriction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cpShapeSetFriction函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: init
static cpSpace *
init(void)
{
ChipmunkDemoMessageString = "Right click and drag to change the blocks's shape.";
cpSpace *space = cpSpaceNew();
cpSpaceSetIterations(space, 30);
cpSpaceSetGravity(space, cpv(0, -500));
cpSpaceSetSleepTimeThreshold(space, 0.5f);
cpSpaceSetCollisionSlop(space, 0.5f);
cpBody *body, *staticBody = cpSpaceGetStaticBody(space);
// Create segments around the edge of the screen.
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(320,-240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
cpFloat width = 50.0f;
cpFloat height = 70.0f;
cpFloat mass = width*height*DENSITY;
cpFloat moment = cpMomentForBox(mass, width, height);
body = cpSpaceAddBody(space, cpBodyNew(mass, moment));
shape = cpSpaceAddShape(space, cpBoxShapeNew(body, width, height));
cpShapeSetFriction(shape, 0.6f);
return space;
}
开发者ID:1103785815,项目名称:wizardwar,代码行数:31,代码来源:Convex.c
示例2: cpSpaceNew
cpSpace *Slice::Init()
{
ChipmunkDemo::Init();
message = "Hold right bottom corner and slice with touch.";
space = cpSpaceNew();
cpSpaceSetIterations(space, 30);
cpSpaceSetGravity(space, cpv(0, -500));
cpSpaceSetSleepTimeThreshold(space, 0.5f);
cpSpaceSetCollisionSlop(space, 0.5f);
cpBody *body, *staticBody = cpSpaceGetStaticBody(space);
cpShape *shape;
// Create segments around the edge of the screen.
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-1000,-240), cpv(1000,-240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
cpFloat width = 200.0f;
cpFloat height = 300.0f;
cpFloat mass = width*height*DENSITY;
cpFloat moment = cpMomentForBox(mass, width, height);
body = cpSpaceAddBody(space, cpBodyNew(mass, moment));
shape = cpSpaceAddShape(space, cpBoxShapeNew(body, width, height, 0.0));
cpShapeSetFriction(shape, 0.6f);
return space;
}
开发者ID:damucz,项目名称:chipmunk2d,代码行数:33,代码来源:Slice.cpp
示例3: init
static cpSpace *
init(void)
{
space = cpSpaceNew();
cpSpaceSetGravity(space, cpv(0, -600));
cpBody *body;
cpShape *shape;
// We create an infinite mass rogue body to attach the line segments too
// This way we can control the rotation however we want.
rogueBoxBody = cpBodyNew(INFINITY, INFINITY);
cpBodySetAngVel(rogueBoxBody, 0.4f);
// Set up the static box.
cpVect a = cpv(-200, -200);
cpVect b = cpv(-200, 200);
cpVect c = cpv( 200, 200);
cpVect d = cpv( 200, -200);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(rogueBoxBody, a, b, 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(rogueBoxBody, b, c, 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(rogueBoxBody, c, d, 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(rogueBoxBody, d, a, 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
cpFloat mass = 1;
cpFloat width = 60;
cpFloat height = 30;
// Add the bricks.
for(int i=0; i<3; i++){
for(int j=0; j<7; j++){
body = cpSpaceAddBody(space, cpBodyNew(mass, cpMomentForBox(mass, width, height)));
cpBodySetPos(body, cpv(i*60 - 150, j*30 - 150));
shape = cpSpaceAddShape(space, cpBoxShapeNew(body, width, height));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.7f);
}
}
return space;
}
开发者ID:meiyunyang,项目名称:chipmunk-physics,代码行数:58,代码来源:Tumble.c
示例4: init
static cpSpace *
init(void)
{
ChipmunkDemoMessageString = "One way platforms are trivial in Chipmunk using a very simple collision callback.";
cpSpace *space = cpSpaceNew();
cpSpaceSetIterations(space, 10);
cpSpaceSetGravity(space, cpv(0, -100));
cpBody *body, *staticBody = cpSpaceGetStaticBody(space);
cpShape *shape;
// Create segments around the edge of the screen.
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(-320,240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(320,-240), cpv(320,240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(320,-240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
// Add our one way segment
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-160,-100), cpv(160,-100), 10.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetCollisionType(shape, COLLISION_TYPE_ONE_WAY);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
// We'll use the data pointer for the OneWayPlatform struct
platformInstance.n = cpv(0, 1); // let objects pass upwards
cpShapeSetUserData(shape, &platformInstance);
// Add a ball to test it out
cpFloat radius = 15.0f;
body = cpSpaceAddBody(space, cpBodyNew(10.0f, cpMomentForCircle(10.0f, 0.0f, radius, cpvzero)));
cpBodySetPosition(body, cpv(0, -200));
cpBodySetVelocity(body, cpv(0, 170));
shape = cpSpaceAddShape(space, cpCircleShapeNew(body, radius, cpvzero));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.9f);
cpShapeSetCollisionType(shape, 2);
cpCollisionHandler *handler = cpSpaceAddWildcardHandler(space, COLLISION_TYPE_ONE_WAY);
handler->preSolveFunc = PreSolve;
return space;
}
开发者ID:00dazam,项目名称:FlappyBird-SpriteBuilder,代码行数:56,代码来源:OneWay.c
示例5: init
static cpSpace *
init(void)
{
ChipmunkDemoMessageString = "Sticky collisions using the cpArbiter data pointer.";
cpSpace *space = cpSpaceNew();
cpSpaceSetIterations(space, 10);
cpSpaceSetGravity(space, cpv(0, -1000));
cpSpaceSetCollisionSlop(space, 2.0);
cpBody *staticBody = cpSpaceGetStaticBody(space);
cpShape *shape;
// Create segments around the edge of the screen.
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-340,-260), cpv(-340, 260), 20.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetCollisionType(shape, COLLIDE_STICK_SENSOR);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv( 340,-260), cpv( 340, 260), 20.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetCollisionType(shape, COLLIDE_STICK_SENSOR);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-340,-260), cpv( 340,-260), 20.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetCollisionType(shape, COLLIDE_STICK_SENSOR);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-340, 260), cpv( 340, 260), 20.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetCollisionType(shape, COLLIDE_STICK_SENSOR);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
for(int i=0; i<200; i++){
cpFloat mass = 0.15f;
cpFloat radius = 10.0f;
cpBody *body = cpSpaceAddBody(space, cpBodyNew(mass, cpMomentForCircle(mass, 0.0f, radius, cpvzero)));
cpBodySetPos(body, cpv(cpflerp(-150.0f, 150.0f, frand()), cpflerp(-150.0f, 150.0f, frand())));
cpShape *shape = cpSpaceAddShape(space, cpCircleShapeNew(body, radius + STICK_SENSOR_THICKNESS, cpvzero));
cpShapeSetFriction(shape, 0.9f);
cpShapeSetCollisionType(shape, COLLIDE_STICK_SENSOR);
}
cpSpaceAddCollisionHandler(space, COLLIDE_STICK_SENSOR, COLLIDE_STICK_SENSOR, NULL, StickyPreSolve, NULL, StickySeparate, NULL);
return space;
}
开发者ID:Adefy,项目名称:AdefyiOS,代码行数:54,代码来源:Sticky.c
示例6: init
static cpSpace *
init(void)
{
ChipmunkDemoMessageString = "Right click to make pentagons static/dynamic.";
cpSpace *space = cpSpaceNew();
cpSpaceSetIterations(space, 5);
cpSpaceSetGravity(space, cpv(0, -100));
cpBody *body, *staticBody = cpSpaceGetStaticBody(space);
cpShape *shape;
// Vertexes for a triangle shape.
cpVect tris[] = {
cpv(-15,-15),
cpv( 0, 10),
cpv( 15,-15),
};
// Create the static triangles.
for(int i=0; i<9; i++){
for(int j=0; j<6; j++){
cpFloat stagger = (j%2)*40;
cpVect offset = cpv(i*80 - 320 + stagger, j*70 - 240);
shape = cpSpaceAddShape(space, cpPolyShapeNew(staticBody, 3, tris, offset));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
}
}
// Create vertexes for a pentagon shape.
cpVect verts[NUM_VERTS];
for(int i=0; i<NUM_VERTS; i++){
cpFloat angle = -2*M_PI*i/((cpFloat) NUM_VERTS);
verts[i] = cpv(10*cos(angle), 10*sin(angle));
}
pentagon_mass = 1.0;
pentagon_moment = cpMomentForPoly(1.0f, NUM_VERTS, verts, cpvzero);
// Add lots of pentagons.
for(int i=0; i<300; i++){
body = cpSpaceAddBody(space, cpBodyNew(pentagon_mass, pentagon_moment));
cpFloat x = rand()/(cpFloat)RAND_MAX*640 - 320;
cpBodySetPos(body, cpv(x, 350));
shape = cpSpaceAddShape(space, cpPolyShapeNew(body, NUM_VERTS, verts, cpvzero));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.4f);
}
return space;
}
开发者ID:Adefy,项目名称:AdefyiOS,代码行数:54,代码来源:Plink.c
示例7: init
static cpSpace *
init(void)
{
cpSpace *space = cpSpaceNew();
cpSpaceSetIterations(space, 30);
cpSpaceSetGravity(space, cpv(0, -100));
cpSpaceSetSleepTimeThreshold(space, 0.5f);
cpSpaceSetCollisionSlop(space, 0.5f);
cpBody *body, *staticBody = cpSpaceGetStaticBody(space);
cpShape *shape;
// Create segments around the edge of the screen.
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(-320,240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(320,-240), cpv(320,240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(320,-240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
// Add lots of boxes.
for(int i=0; i<14; i++){
for(int j=0; j<=i; j++){
body = cpSpaceAddBody(space, cpBodyNew(1.0f, cpMomentForBox(1.0f, 30.0f, 30.0f)));
cpBodySetPosition(body, cpv(j*32 - i*16, 300 - i*32));
shape = cpSpaceAddShape(space, cpBoxShapeNew(body, 30.0f, 30.0f, 0.5f));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.8f);
}
}
// Add a ball to make things more interesting
cpFloat radius = 15.0f;
body = cpSpaceAddBody(space, cpBodyNew(10.0f, cpMomentForCircle(10.0f, 0.0f, radius, cpvzero)));
cpBodySetPosition(body, cpv(0, -240 + radius+5));
shape = cpSpaceAddShape(space, cpCircleShapeNew(body, radius, cpvzero));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.9f);
return space;
}
开发者ID:ConfusedReality,项目名称:pkg_game-engine_chipmunk,代码行数:51,代码来源:PyramidStack.c
示例8: Shell
Shell(cpVect pos, cpVect vel, float angle)
{
cpVect vl[4] = {cpv(0, 0), cpv(0.1, 0), cpv(0.07, 0.3), cpv(0.03, 0.3)};
int vn = sizeof(vl)/sizeof(cpVect);
float mass = cpAreaForPoly(vn, vl, 0) * shell_density;
float moi = cpMomentForPoly(mass, vn, vl, cpv(0, 0), 0);
body = cpBodyNew(mass, moi);
cpshape = cpPolyShapeNew(body, vn, vl, cpTransformIdentity, 0);
cpShapeSetFriction(cpshape, 0.9);
cpVect centroid = cpCentroidForPoly(vn, vl);
shape.setPointCount(vn);
for (int i = 0; i < vn; i++)
{
shape.setPoint(i, sf::Vector2f(vl[i].x, vl[i].y));
}
cpBodySetCenterOfGravity(body, centroid);
cpBodySetPosition(body, pos-centroid);
cpBodySetVelocity(body, vel);
cpBodySetAngle(body, angle);
cpShapeSetCollisionType(cpshape, 2);
cpShapeSetUserData(cpshape, this);
}
开发者ID:cyclohexanamine,项目名称:shipbrain,代码行数:28,代码来源:main.cpp
示例9: cpShapeSetFriction
void PhysicsShape::setFriction(qreal v)
{
m_friction = v;
if(m_isPhysicsCreated) {
cpShapeSetFriction(m_shape, v);
}
}
开发者ID:ccera,项目名称:QuickPhysics,代码行数:7,代码来源:physicsshape.cpp
示例10: _shape_add
static unsigned int _shape_add(Entity ent, PhysicsShape type, cpShape *shape)
{
PhysicsInfo *info;
ShapeInfo *shapeInfo;
info = entitypool_get(pool, ent);
error_assert(info);
/* init ShapeInfo */
shapeInfo = array_add(info->shapes);
shapeInfo->type = type;
shapeInfo->shape = shape;
/* init cpShape */
cpShapeSetBody(shape, info->body);
cpSpaceAddShape(space, shape);
cpShapeSetFriction(shapeInfo->shape, 1);
cpShapeSetUserData(shapeInfo->shape, ent);
/* update moment */
if (!cpBodyIsStatic(info->body))
{
if (array_length(info->shapes) > 1)
cpBodySetMoment(info->body, _moment(info->body, shapeInfo)
+ cpBodyGetMoment(info->body));
else
cpBodySetMoment(info->body, _moment(info->body, shapeInfo));
}
return array_length(info->shapes) - 1;
}
开发者ID:andi2,项目名称:cgame,代码行数:31,代码来源:physics.c
示例11: core_add_static_box_shape
// adds static box shape to space
static void core_add_static_box_shape ( cpSpace * space, Box * box ) {
// add box collision shape to body
cpFloat hw = box->width / 2.0;
cpFloat hh = box->height / 2.0;
double x = box->x;
double y = box->y;
cpVect verts[] = {
cpv ( x - hw, y - hh ),
cpv ( x - hw, y + hh ),
cpv ( x + hw, y + hh ),
cpv ( x + hw, y - hh ),
};
cpShape * box_shape = cpPolyShapeNew ( space->staticBody, 4, verts, cpvzero );
cpShapeSetFriction ( (cpShape *) box_shape, box->friction );
cpShapeSetElasticity ( (cpShape *) box_shape, box->elasticity );
cpSpaceAddPostStepCallback ( space, (cpPostStepFunc) postStepAddShape, box_shape, NULL );
DrawShapeInfo *info = add_box_draw_shape_info ( box );
box_shape->data= ( cpDataPointer ) info;
}
开发者ID:nicole-hedley,项目名称:asteroid-game,代码行数:27,代码来源:core.c
示例12: post_step_body_replace_shapes
static void post_step_body_replace_shapes(cpSpace *space, cpBody *body, void *data) {
Body_data *pa = cpBodyGetUserData(body);
int length = pa->x_values->len;
cpBodyEachShape(body, (cpBodyShapeIteratorFunc) free_shape, NULL);
cpSpaceReindexShapesForBody(space, body);
//fprintf(stderr, "0Made it this far.\n");
for (int index = 1; index < length; index++) {
cpFloat x = g_array_index(pa->x_values, cpFloat, index);
cpFloat y = g_array_index(pa->y_values, cpFloat, index);
cpShape *seg = cpSegmentShapeNew(body, cpv(x,y), cpv(g_array_index(pa->x_values, cpFloat, index - 1), g_array_index(pa->y_values, cpFloat, index - 1)), CRAYON_RADIUS);
//fprintf(stderr, "1Made it this far.\n");
cpShapeSetFriction(seg, CRAYON_FRICTION);
//fprintf(stderr, "2Made it this far.\n");
//cpShapeSetElasticity(cpShape *shape, cpFloat value)?
cpSpaceAddShape(space, seg);
//fprintf(stderr, "3Made it this far.\n");
}
cpSpaceReindexShapesForBody(space, body);
}
开发者ID:outgame,项目名称:CrayonPhysics,代码行数:25,代码来源:physics.c
示例13: add_box
static void
add_box(cpSpace *space)
{
const cpFloat size = 10.0f;
const cpFloat mass = 1.0f;
cpVect verts[] = {
cpv(-size,-size),
cpv(-size, size),
cpv( size, size),
cpv( size,-size),
};
cpFloat radius = cpvlength(cpv(size, size));
cpVect pos = rand_pos(radius);
cpBody *body = cpSpaceAddBody(space, cpBodyNew(mass, cpMomentForPoly(mass, 4, verts, cpvzero, 0.0f)));
body->velocity_func = planetGravityVelocityFunc;
cpBodySetPosition(body, pos);
// Set the box's velocity to put it into a circular orbit from its
// starting position.
cpFloat r = cpvlength(pos);
cpFloat v = cpfsqrt(gravityStrength / r) / r;
cpBodySetVelocity(body, cpvmult(cpvperp(pos), v));
// Set the box's angular velocity to match its orbital period and
// align its initial angle with its position.
cpBodySetAngularVelocity(body, v);
cpBodySetAngle(body, cpfatan2(pos.y, pos.x));
cpShape *shape = cpSpaceAddShape(space, cpPolyShapeNew(body, 4, verts, cpTransformIdentity, 0.0));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.7f);
}
开发者ID:Ben-G,项目名称:spritebuilder-angrybirds,代码行数:35,代码来源:Planet.c
示例14: __declspec
__declspec( dllexport ) void push( const void * _in, int in_size, void * _out, int out_sz )
{
int index;
Variable *var;
cpBody *body;
cpShape *shape;
index = PEEKINT(INPUT_MEMBLOCK,0);
var = vhGetVariable(&mVariableHandler,index);
switch (var->mType)
{
case VarTypeBody:
body = (cpBody*)var->mPtr;
cpBodySetAngle(body,degToRad(PEEKFLOAT(INPUT_MEMBLOCK,4)));
cpBodySetPos(body,PEEKVECT(INPUT_MEMBLOCK,8));
cpBodySetAngVel(body,degToRad(PEEKFLOAT(INPUT_MEMBLOCK,16)));
cpBodySetVel(body,PEEKVECT(INPUT_MEMBLOCK,20));
break;
case VarTypeShape:
shape = (cpShape*)var->mPtr;
cpShapeSetFriction(shape,PEEKFLOAT(INPUT_MEMBLOCK,4));
cpShapeSetElasticity(shape,PEEKFLOAT(INPUT_MEMBLOCK,8));
cpShapeSetLayers(shape,PEEKUINT(INPUT_MEMBLOCK,12));
cpShapeSetGroup(shape,PEEKUINT(INPUT_MEMBLOCK,16));
break;
}
}
开发者ID:Latexi95,项目名称:cbChipmunk,代码行数:29,代码来源:cbchipmunk.c
示例15: new
bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
{
cpVect* vec = nullptr;
do
{
_type = Type::EDGECHAIN;
vec = new (std::nothrow) cpVect[count];
PhysicsHelper::points2cpvs(points, vec, count);
int i = 0;
for (; i < count - 1; ++i)
{
auto shape = cpSegmentShapeNew(s_sharedBody, vec[i], vec[i + 1], border);
CC_BREAK_IF(shape == nullptr);
cpShapeSetUserData(shape, this);
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
addShape(shape);
}
CC_SAFE_DELETE_ARRAY(vec);
CC_BREAK_IF(i < count - 1);
_mass = PHYSICS_INFINITY;
_moment = PHYSICS_INFINITY;
setMaterial(material);
return true;
} while (false);
CC_SAFE_DELETE_ARRAY(vec);
return false;
}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:35,代码来源:CCPhysicsShape.cpp
示例16: do_logic
static void
do_logic(game_state *state)
{
switch_state_data *data = state->data->switch_data;
if (data->mouse_down_last_step && state->game->mouse_down == false)
{
/* clicked and released; create a circle */
cpFloat radius = 15;
cpFloat mass = 10;
cpFloat moment = cpMomentForCircle(mass, 0, radius, cpvzero);
cpBody *ball = cpSpaceAddBody(data->space, cpBodyNew(mass, moment));
cpBodySetPos(ball, state->game->mouse_pos);
cpShape *ball_shape = cpSpaceAddShape(data->space,
cpCircleShapeNew(ball, radius, cpvzero));
cpShapeSetElasticity(ball_shape, 0.7);
cpShapeSetFriction(ball_shape, 0.7);
cpShapeSetLayers(ball_shape, L_PLAYER);
}
cpSpaceStep(data->space, TARGET_SEC_PER_FRAME);
data->mouse_down_last_step = state->game->mouse_down;
if (ent_switch_get_state(data->sw))
debug_puts("switch is on");
else
debug_puts("switch is off");
}
开发者ID:hdgarrood,项目名称:swinging-game,代码行数:31,代码来源:switch_state.c
示例17: cpShapeSetFriction
void PhysicsShape::setFriction(float friction)
{
_material.friction = friction;
for (cpShape* shape : _cpShapes)
{
cpShapeSetFriction(shape, friction);
}
}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:9,代码来源:CCPhysicsShape.cpp
示例18: cpShapeSetFriction
void PhysicsShape::setFriction(float friction)
{
_material.friction = friction;
for (cpShape* shape : _cpShapes)
{
cpShapeSetFriction(shape, PhysicsHelper::float2cpfloat(friction));
}
}
开发者ID:kaiqinetwork,项目名称:cocos2d-x,代码行数:9,代码来源:CCPhysicsShape.cpp
示例19: MessageBox
void Player::Initialize(void)
{
// Load the texture
if (!(this->m_Texture = this->m_Hge->Texture_Load("data/particles.png")))
{
MessageBox(NULL, "Can't load particles.png texture.", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
this->m_Engine->Shutdown();
return;
}
// Create the player sprite
this->m_Sprite = new hgeSprite(this->m_Texture, 60, 40, 20, 20);
this->m_Sprite->SetColor(this->m_Color);
this->m_Sprite->SetHotSpot(10, 10);
// Create the particle sprite
this->m_ParticleSprite = new hgeSprite(this->m_Texture, 20, 20, 20, 20);
this->m_ParticleSprite->SetBlendMode(BLEND_COLORMUL | BLEND_ALPHAADD | BLEND_NOZWRITE);
this->m_ParticleSprite->SetHotSpot(10, 10);
// Create the particle system
this->m_ParticleSystem = new hgeParticleSystem("data/trail.psi", this->m_ParticleSprite);
this->m_ParticleSystem->Fire();
// Initialize the weapon slots
this->m_Weaponslots = (Weapon**) malloc(sizeof(Weapon*) * NUM_WEAPON_SLOTS);
for (int i = 0 ; i < NUM_WEAPON_SLOTS ; ++i)
{
this->m_Weaponslots[i] = 0;
}
this->m_Weaponslots[0] = new Neoshooter(this, this->m_Engine->GetWorld());
// Initialize physics
{
// Define moment
cpFloat moment = cpMomentForCircle(1, 0, 10, cpvzero);
// Fetch the physics space
cpSpace *space = this->m_Engine->GetWorld()->GetSpace();
// Add the physics body
this->m_Body = cpSpaceAddBody(space, cpBodyNew(1, moment));
cpBodySetPos(this->m_Body, this->m_Position);
// Add the physics shape
this->m_Shape = cpSpaceAddShape(space, cpCircleShapeNew(this->m_Body, 10, cpvzero));
this->m_Shape->data = this;
this->m_Shape->collision_type = COLLISION_TYPE_GO;
cpShapeSetElasticity(this->m_Shape, 1.0f);
cpShapeSetFriction(this->m_Shape, 0.7);
// Define the collision handlers for various types of collisions
cpSpaceAddCollisionHandler(space, COLLISION_TYPE_GO, COLLISION_TYPE_ACTIVATOR, BeginCollisionD, NULL, NULL, SeparateCollisionD, this);
cpSpaceAddCollisionHandler(space, COLLISION_TYPE_GO, COLLISION_TYPE_BULLET, BeginCollisionD, NULL, NULL, NULL, this);
}
}
开发者ID:ofx,项目名称:dr,代码行数:57,代码来源:Player.cpp
示例20: cpSpaceAddBody
static cpBody *MakeBody(const float x, const float y, const float w)
{
cpBody *body = cpSpaceAddBody(space.Space, cpBodyNewStatic());
cpBodySetPosition(body, cpv(x + w / 2, y - GAP_HEIGHT / 2));
cpShape *shape = cpSpaceAddShape(
space.Space, cpBoxShapeNew(body, w, GAP_HEIGHT, 0.0));
cpShapeSetElasticity(shape, BLOCK_ELASTICITY);
cpShapeSetFriction(shape, 1.0f);
return body;
}
开发者ID:gameblabla,项目名称:fallingtime,代码行数:10,代码来源:box.c
注:本文中的cpShapeSetFriction函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论