当前位置: 首页>>代码示例>>C++>>正文


C++ Body::_方法代码示例

本文整理汇总了C++中Body::_方法的典型用法代码示例。如果您正苦于以下问题:C++ Body::_方法的具体用法?C++ Body::_怎么用?C++ Body::_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Body的用法示例。


在下文中一共展示了Body::_方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ChipmunkRecorder_apply_frame

void ChipmunkRecorder_apply_frame(struct Recorder *recorder, void *frame) {
    check(recorder != NULL, "No recorder to apply");
    check(frame != NULL, "No recorder to apply");
    check(recorder->entity != NULL, "No entity to apply recording to");

    Body *body = recorder->entity->body;
    Sprite *sprite = recorder->entity->sprite;

    ChipmunkRecorderCtx *context = (ChipmunkRecorderCtx *)recorder->context;
    ChipmunkRecorderFrame *f = (ChipmunkRecorderFrame *)frame;
    if (f->keyframe) {
        body->_(set_pos)(body, f->pos);
        body->_(set_velo)(body, f->velo);
        sprite->current_frame = f->sprite_frame;
        sprite->direction = f->sprite_direction;
    } else {
        if (f->has_delta_pos) {
            VPoint pos = body->_(get_pos)(body);
            pos = VPoint_add(pos, f->pos);
            body->_(set_pos)(body, pos);
        }
        if (f->has_delta_velo) {
            VPoint velo = body->_(get_velo)(body);
            velo = VPoint_add(velo, f->velo);
            body->_(set_velo)(body, velo);
        }
        if (f->has_sprite_frame) {
            sprite->current_frame = f->sprite_frame;
        }
        if (f->has_sprite_direction) {
            sprite->direction = f->sprite_direction;
        }
    }
    context->prev_frame = f;

    return;
error:
    return;
}
开发者ID:levicole,项目名称:dabes_engine,代码行数:39,代码来源:chipmunk_recorder.c

示例2: check

void *ChipmunkRecorder_capture_frame(Recorder *recorder, size_t *size) {
    check(recorder != NULL, "No recorder to capture");
    check(recorder->entity != NULL, "No entity to capture recording of");

    ChipmunkRecorderFrame *frame = calloc(1, sizeof(ChipmunkRecorderFrame));
    check(frame != NULL, "Couldn't create frame");

    // is this a keyframe?
    ChipmunkRecorderCtx *context = (ChipmunkRecorderCtx *)recorder->context;
    short int is_keyframe =
        (recorder->current_frame % context->keyframe_every) == 0;
    if (recorder->entity->force_keyframe) {
        is_keyframe = 1;
        recorder->entity->force_keyframe = 0;
    }
  
    frame->keyframe = is_keyframe;

    Body *body = recorder->entity->body;
    Sprite *sprite = recorder->entity->sprite;
    if (is_keyframe) {
        frame->pos = body->_(get_pos)(body);
        frame->velo = body->_(get_velo)(body);
        frame->sprite_frame = sprite->current_frame;
        frame->sprite_direction = sprite->direction;
        memcpy(&context->tracking_frame, frame, sizeof(ChipmunkRecorderFrame));
        *size = sizeof(ChipmunkRecorderFrame);
    } else {
        size_t f_size = sizeof(unsigned char);

        VPoint posnow = body->_(get_pos)(body);
        VPointRel posrel = VPoint_rel(posnow, context->tracking_frame.pos);
        if (posrel != VPointRelWithin) {
            frame->has_delta_pos = 1;
            frame->pos = VPoint_subtract(posnow, context->tracking_frame.pos);
            context->tracking_frame.pos = posnow;
            f_size += sizeof(VPoint);
        }

        VPoint velonow = body->_(get_velo)(body);
        VPointRel velorel = VPoint_rel(velonow, context->tracking_frame.velo);
        if (velorel != VPointRelWithin) {
            frame->has_delta_velo = 1;
            frame->velo =
                VPoint_subtract(velonow, context->tracking_frame.velo);
            context->tracking_frame.velo = velonow;
            f_size += sizeof(VPoint);
        }
      
        if (sprite->current_frame != context->tracking_frame.sprite_frame) {
            frame->has_sprite_frame = 1;
            frame->sprite_frame = sprite->current_frame;
            context->tracking_frame.sprite_frame = sprite->current_frame;
            f_size += sizeof(int);
        }

        if (sprite->direction != context->tracking_frame.sprite_direction) {
            frame->has_sprite_direction = 1;
            frame->sprite_direction = sprite->direction;
            context->tracking_frame.sprite_direction = sprite->direction;
            f_size += sizeof(int);
        }
      
        *size = f_size;
    }

    context->prev_frame = frame;
    return frame;
error:
    return NULL;
}
开发者ID:levicole,项目名称:dabes_engine,代码行数:71,代码来源:chipmunk_recorder.c

示例3: ChipmunkRecorder_stop_play_cb

void ChipmunkRecorder_stop_play_cb(struct Recorder *recorder) {
    recorder->entity->sprite->manual_frames = 0;
    recorder->entity->auto_control = 0;
    Body *body = recorder->entity->body;
    body->_(set_is_rogue)(body, 0);
}
开发者ID:levicole,项目名称:dabes_engine,代码行数:6,代码来源:chipmunk_recorder.c


注:本文中的Body::_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。