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


C++ ObjectRef::getZIndex方法代码示例

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


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

示例1: objectTransform

// this is the trickest part in the program, because we need to output the objects in each timeline (each timeline
// describes one object), but we need to keep refering back to the mainline to see if the object is attached to any
// bones, and if so, calculate how this affects the final position of the object
// Note that we're only interested in exporting objects - not bones
std::ostream& operator<< (std::ostream& out, const Timeline& timeline) {
    
    if(!timeline.isTypeObject())
        return out;
    
    out << "\t\t[" << timeline.m_id + 1 << "] = {" << endl;
    for(vector<Object*>::const_iterator it = timeline.m_objects.begin(); it != timeline.m_objects.end(); ) {
        // For each object we have to check if it is attached to a bone. If it is, then
        // we need to recursively look up the bone's properties and calculate the values to add to the
        // object position.
        
        Object* object = *it;
        
        // search the mainline for any references to this timeline and key pair
        int mainlineKeyId;
        ObjectRef* objectRef = timeline.m_owner->findReferenceToObject(timeline.m_id, object->getId(), &mainlineKeyId);
                
        
        Transform objectTransform(object->getX(), object->getY(), object->getAngle(), object->getScaleX(), object->getScaleY());
        BoneRef* boneRef = timeline.m_owner->getBoneReference(objectRef, mainlineKeyId);
        Transform parentTransform = timeline.buildTransform(boneRef, mainlineKeyId);
        objectTransform.apply_parent_transform(parentTransform);
        
        float x = objectTransform.x;
        float y = objectTransform.y;
        int z = objectRef->getZIndex();
        float angle = objectTransform.angle;
        float scaleX = objectTransform.scale_x;
        float scaleY = objectTransform.scale_y;
                
        out << "\t\t\t[" << object->getId() + 1 << "] = {" << endl;
                    
        out << "\t\t\t\t['angle'] = " << boost::format("%.4f") % angle << "," << endl;
        out << "\t\t\t\t['texture'] = '" << timeline.m_owner->getFileName(object->getFolder(), object->getFile()) << "'," << endl;
        out << "\t\t\t\t['zindex'] = " << z << "," << endl;
        out << "\t\t\t\t['scale_x'] = " << boost::format("%.4f") % scaleX << "," << endl;
        out << "\t\t\t\t['scale_y'] = " << boost::format("%.4f") % scaleY << "," << endl;
        out << "\t\t\t\t['time'] = " << object->getTime() << "," << endl;
        out << "\t\t\t\t['x'] = " << boost::format("%.6f") % x << "," << endl;
        out << "\t\t\t\t['y'] = " << boost::format("%.6f") % y << "," << endl;
        out << "\t\t\t\t['spin'] = " << object->getSpin() << "," << endl;
        out << "\t\t\t\t['pivot_x'] = " << 0 << "," << endl;
        out << "\t\t\t\t['pivot_y'] = " << timeline.m_owner->getFile(object->getFolder(), object->getFile())->getHeight()<< endl;
        
        out << "\t\t\t}";
        if(++it != timeline.m_objects.end())
            out << ", ";
        out << endl;
    }
    out << "\t\t}";
    return out;
}
开发者ID:samuchan,项目名称:NekoPunch,代码行数:56,代码来源:timeline.cpp


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