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


C++ MapObject类代码示例

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


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

示例1: assert

void CMapObjectManager::update(float dt)
{
	MapObject* array[1024] = {0};
	int len = 0;
	assert(m_Objects.size() < 1024);
	for ( MapObjectList::iterator itr = m_Objects.begin();itr != m_Objects.end(); )
	{
		MapObject* pObject = *itr;

		// 清理掉被标记为删除的,和没有地图的野对象
		if ( !pObject || pObject->GetDeleted() || !pObject->GetMap() )
		{
			CC_SAFE_RELEASE(pObject);
			itr = m_Objects.erase(itr);
			continue;
		}

		// 合法的对象加入新的列表
		array[len++] = pObject;
		pObject->retain();
		++itr;
	}

	// 对新列表按照遮挡关系排序
	//qsort(array,len,sizeof(MapObject*),(int (__cdecl *)(const void *,const void *))compare);
	sortZorder(array,len);
	
	for ( int i = 0;i<len;++i )
	{
		array[i]->setLocalZOrder(len-i);
		array[i]->update(dt);
		array[i]->release();
		array[i] = NULL;
	}
}
开发者ID:SmallRaindrop,项目名称:LocatorApp,代码行数:35,代码来源:MapObjectManager.cpp

示例2: toMapObject

QModelIndex MapObjectModel::parent(const QModelIndex &index) const
{
    MapObject *mapObject = toMapObject(index);
    if (mapObject)
        return this->index(mapObject->objectGroup());
    return QModelIndex();
}
开发者ID:twuni,项目名称:tiled,代码行数:7,代码来源:mapobjectmodel.cpp

示例3: MapObject

void SpawnDetailDoodadsCommand::redo()
{
    /*if(object)
        delete object; // crash
*/

    for(int i = 0; i < spawnData.count(); ++i)
    {
        QVector<QPair<QString, QVector3D>> resultData = spawnData[i];

        for(int j = 0; j < resultData.count(); ++j)
        {
            QPair<QString, QVector3D> pair = resultData[j];

            // todo rotation based on heightmap bounding boxes
            MapObject* object = new MapObject(world->getModelManager()->getModel(world->getModelManager()->getIndex(pair.first)));
            object->setTranslate(pair.second, false);
            object->setRotation(QVector3D(0.0f, 0.0f, 0.0f));
            object->setScale(QVector3D(1.0f, 1.0f, 1.0f));
            object->updateBoundingBox();

            objects.append(object);

            world->addObject(object);
        }
    }
}
开发者ID:zhenyouluo,项目名称:QEditor,代码行数:27,代码来源:undoredomanager.cpp

示例4: m_Split

//private
void BodyCreator::m_Split(const MapObject& object, b2Body* body)
{
	//check object shapes is valid
	if (!m_CheckShape(const_cast<MapObject&>(object))) return;

	const Shape& points = object.PolyPoints();
	Shapes shapes;
	if (object.Convex())
		shapes = m_ProcessConvex(points);
	else
		shapes = m_ProcessConcave(points);

	for (auto& shape : shapes)
	{
		sf::Uint16 s = shape.size();

		if (s > b2_maxPolygonVertices)
		{
			//break into smaller and append
			Shapes moreShapes = m_ProcessConvex(shape);
			for (auto& anotherShape : moreShapes)
				m_CreateFixture(anotherShape, body);

			continue; //skip shape because it's too big
		}
		m_CreateFixture(shape, body);
	}
}
开发者ID:Stephen321,项目名称:3rdYearProject,代码行数:29,代码来源:BodyCreator.cpp

示例5: SelectObjects

MapObject*	CMapObjectManager::SelectObject(float x,float y,MapObject* pExclude )
{
	MapObjectList objects;
	SelectObjects(x,y,objects);

	MapObject* pRet = NULL; 
	for ( size_t i = 0;i<objects.size();++i )
	{
		MapObject* pObject = objects[i];
		if ( pObject == pExclude || pObject->GetDeleted())
		{
			continue;
		}

		if ( !pRet )
		{
			pRet = pObject;
			continue;
		}

		if ( pRet->getZOrder() < pObject->getZOrder() )
		{
			pRet = pObject;
		}
	}

	return pRet;
}
开发者ID:SmallRaindrop,项目名称:LocatorApp,代码行数:28,代码来源:MapObjectManager.cpp

示例6: stream

/**
 * Accepts dropping a single template into an object group
 */
void MapScene::dropEvent(QGraphicsSceneDragDropEvent *event)
{
    const QMimeData *mimeData = event->mimeData();

    ObjectGroup *objectGroup = dynamic_cast<ObjectGroup*>(mapDocument()->currentLayer());
    if (!objectGroup || !mimeData->hasFormat(QLatin1String(TEMPLATES_MIMETYPE)))
        return;

    QByteArray encodedData = mimeData->data(QLatin1String(TEMPLATES_MIMETYPE));
    QDataStream stream(&encodedData, QIODevice::ReadOnly);

    TemplateManager *templateManager = TemplateManager::instance();

    QString fileName;
    stream >> fileName;

    const ObjectTemplate *objectTemplate = templateManager->findObjectTemplate(fileName);
    if (!objectTemplate)
        return;

    MapObject *newMapObject = new MapObject();
    newMapObject->setObjectTemplate(objectTemplate);
    newMapObject->syncWithTemplate();
    newMapObject->setPosition(event->scenePos());

    auto addObjectCommand = new AddMapObject(mapDocument(),
                                             objectGroup,
                                             newMapObject);

    mapDocument()->undoStack()->push(addObjectCommand);

    mapDocument()->setSelectedObjects(QList<MapObject*>() << newMapObject);
}
开发者ID:dorkster,项目名称:tiled,代码行数:36,代码来源:mapscene.cpp

示例7:

int	CMapObjectManager::getObjectsInView(MapObjectType type,MapObjectList& objects)
{
	Rect rect;
	m_pMap->getViewRect(rect);

	float x = 0;
	float y = 0;

	for ( MapObjectList::iterator itr = m_Objects.begin();itr != m_Objects.end();++itr)
	{
		MapObject* pObject = *itr;
		if ( pObject && !pObject->GetDeleted() )
		{
			x = pObject->getPositionX();
			y = pObject->getPositionY();

			if ( rect.containsPoint(Point(x,y)) && pObject->GetType() == type )
			{
				objects.push_back(pObject);
			}
		}
	}

	return (int)objects.size();
}
开发者ID:SmallRaindrop,项目名称:LocatorApp,代码行数:25,代码来源:MapObjectManager.cpp

示例8: if

// EDIT
void MapLayer::Add(int number, int x, int y, int option, bool initial){
    if(number == 0) return;
    
    MapObject *obj = nullptr;
    
    if(number < 10){    // tile
        if(!initial && mapData[y][x] != 0){
            this->removeChildByTag(y*width+x);
        }
        mapData[y][x] = number;
    }
    else if(number < 100){  // obstacle
        for(MapObject *obstacle : obstacleList){
            MapObjectInfo info = obstacle->GetInfo();
            if(info.x == x && info.y == y)
                return;
        }
        if(number == 20){
            mapData[y][x] = 1;
            mapData[y+1][x] = 1;
        }
    }
    else{   // object
        for(MapObject *object : objectList){
            MapObjectInfo info = object->GetInfo();
            if(info.x == x && info.y == y)
                return;
        }
    }
    
    obj = MapObject::create(number, x, y, option);
    obj->setTag(y*width+x);
    this->addChild(obj);
}
开发者ID:gnosy1590,项目名称:projectWhipping,代码行数:35,代码来源:MapLayer.cpp

示例9: Q_ASSERT

void CreateObjectTool::startNewMapObject(const QPointF &pos,
                                         ObjectGroup *objectGroup)
{
    Q_ASSERT(!mNewMapObjectItem);

    MapObject *newMapObject = new MapObject;
    newMapObject->setPosition(pos);

    if (mMode == CreatePolygon || mMode == CreatePolyline) {
        MapObject::Shape shape = mMode == CreatePolygon ? MapObject::Polygon
                                                        : MapObject::Polyline;
        QPolygonF polygon;
        polygon.append(QPointF());
        newMapObject->setPolygon(polygon);
        newMapObject->setShape(shape);

        polygon.append(QPointF()); // The last point is connected to the mouse
        mOverlayPolygonObject->setPolygon(polygon);
        mOverlayPolygonObject->setShape(shape);
        mOverlayPolygonObject->setPosition(pos);

        mOverlayPolygonItem = new MapObjectItem(mOverlayPolygonObject,
                                                mapDocument());
        mapScene()->addItem(mOverlayPolygonItem);
    }

    objectGroup->addObject(newMapObject);

    mNewMapObjectItem = new MapObjectItem(newMapObject, mapDocument());
    mapScene()->addItem(mNewMapObjectItem);
}
开发者ID:Zeitmaus,项目名称:tiled,代码行数:31,代码来源:createobjecttool.cpp

示例10: MapObject

MapObject* ObjectFactory::createMapObject(const char *idMapObject, b2World *world)
{
    MapObject* mapObject = NULL;
    
    mapObject = new MapObject();
    
    //sprite
    const char* nameSprite = (std::string( idMapObject) + std::string(".png")).c_str();
    
    CCSprite* sprite=CCSprite::createWithSpriteFrameName(nameSprite);
    
    //body
    b2BodyDef bodyDef;
    bodyDef.type = b2_staticBody;
    bodyDef.angle = ccpToAngle(ccp(0,0));
    
    b2Body *body = world->CreateBody(&bodyDef);
    
    gbox2d::GB2ShapeCache *sc =  gbox2d::GB2ShapeCache::sharedGB2ShapeCache();
    sc->addFixturesToBody(body, idMapObject);
    sprite->setAnchorPoint(sc->anchorPointForShape(idMapObject));
    
    mapObject->setSkin(body, sprite);
    mapObject->onCreate();
    
    return mapObject;
    
}
开发者ID:quinsmpang,项目名称:TinyZodiacs,代码行数:28,代码来源:ObjectFactory.cpp

示例11: groupIndexesByObject

void EditPolygonTool::splitSegments()
{
    if (mSelectedHandles.size() < 2)
        return;

    const PointIndexesByObject p = groupIndexesByObject(mSelectedHandles);
    QMapIterator<MapObject*, RangeSet<int> > i(p);

    QUndoStack *undoStack = mapDocument()->undoStack();
    bool macroStarted = false;

    while (i.hasNext()) {
        MapObject *object = i.next().key();
        const RangeSet<int> &indexRanges = i.value();

        const bool closed = object->shape() == MapObject::Polygon;
        QPolygonF oldPolygon = object->polygon();
        QPolygonF newPolygon = splitPolygonSegments(oldPolygon, indexRanges,
                                                    closed);

        if (newPolygon.size() > oldPolygon.size()) {
            if (!macroStarted) {
                undoStack->beginMacro(tr("Split Segments"));
                macroStarted = true;
            }

            undoStack->push(new ChangePolygon(mapDocument(), object,
                                              newPolygon,
                                              oldPolygon));
        }
    }

    if (macroStarted)
        undoStack->endMacro();
}
开发者ID:Shorttail,项目名称:tiled,代码行数:35,代码来源:editpolygontool.cpp

示例12: setSelectedHandle

void EditPolygonTool::startMoving()
{
    // Move only the clicked handle, if it was not part of the selection
    if (!mSelectedHandles.contains(mClickedHandle))
        setSelectedHandle(mClickedHandle);

    mMode = Moving;

    MapRenderer *renderer = mapDocument()->renderer();

    // Remember the current object positions
    mOldHandlePositions.clear();
    mOldPolygons.clear();
    mAlignPosition = renderer->screenToPixelCoords((*mSelectedHandles.begin())->pos());

    const auto &selectedHandles = mSelectedHandles;
    for (PointHandle *handle : selectedHandles) {
        const QPointF pos = renderer->screenToPixelCoords(handle->pos());
        mOldHandlePositions.append(handle->pos());
        if (pos.x() < mAlignPosition.x())
            mAlignPosition.setX(pos.x());
        if (pos.y() < mAlignPosition.y())
            mAlignPosition.setY(pos.y());

        MapObject *mapObject = handle->mapObject();
        if (!mOldPolygons.contains(mapObject))
            mOldPolygons.insert(mapObject, mapObject->polygon());
    }
}
开发者ID:Shorttail,项目名称:tiled,代码行数:29,代码来源:editpolygontool.cpp

示例13: foreach

void Map::draw()
{
  MapObject * o = 0;
  foreach(MapObjectList, o, mMapObjects) {
    o->setAlpha(getOpacity(o->pos()));
    o->draw();
  }
开发者ID:pecore,项目名称:LEFT,代码行数:7,代码来源:Map.cpp

示例14: MapObject

MapObject* LevelObjectCreator::sCreateMapAnimations(int index, const char* spriteName)
{
	MapObject* object = new MapObject(spriteName, index, index * 2);				
	object->autorelease();

	return object;
}
开发者ID:JamShan,项目名称:xcode_jifengyongzhezhuan,代码行数:7,代码来源:LevelObjectCreator.cpp

示例15: Layer

ObjectLayer::ObjectLayer(const QString &name, int x, int y, int w, int h) :
    Layer(name, x, y, w, h)
{
    QPixmap img(":/Images/coin_gold.png");
    MapObject *obj = new MapObject("test", "thing", QPoint(100, 100), img.size());
    obj->setImage(img);
    addObject(obj);
}
开发者ID:ATSOTECK,项目名称:Aurora-Game-Editor,代码行数:8,代码来源:ObjectLayer.cpp


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