Forums

OverviewFelgo 2 Support (Qt 5) › cameraVPlay question

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #16018

    Darren

    Hi guys,

    I am now using cameraVPlay in my level editor with the following behaviours:

    1. When level editing the camera is in free mode and can be dragged to display different parts of the game area.
    2. When I click on an entity, the camera centres on that entity.  At this point my level editor also opens up an entity editor that I have created.

    I have managed this behaviour by setting – mouseArea.propagateComposedEvents: true – within my cameraVPlay component.  This allows for the click to be ignored by the cameraVPlay.mouseArea and instead handled by my entity which sits beneath it.  This is how I have managed to make it possible to click on the entity whilst level editing.

     

    Whilst I am editing the entity I need to be able to drag the entity to other parts of the screen – allowing the user to reposition it.  I also want to be able to zoom in and out using pinchZoom.

    In order to achieve the behaviour of dragging the entity around the screen, I need to temporarily turn off the drag feature of cameraVPlay.  I have achieved this so far by disabling the mouseArea with – camera.mouseAreaEnabled = false.

    Unfortunately this also turns off the pinchZoom.

     

    Is it possible, whilst in camera free-move mode, to either disable the drag feature, or to propagate the drag to an object behind the camera – so that it could be handled by my draggable entity?

     

    The – mouseArea.propagateComposedEvents: true – does not propagate the drag event to the entity beneath the camera.  I assume because the cameraVPlay.mouseArea has a handler for the drag event.

     

    Can you see a way around this issue?

    If it is not possible, I do have another solution by using a slider to zoom in / out instead of pinchZoom, but would prefer to use pinchZoom if possible.

     

    I have copied the relevant part of my code below if that helps…

     

    Thank you

     

    Darren.

     

     

    Connections{
            target: levelUI
            onEntityBeingEdited:{//(entityToEdit) - signal recieved with details of entity being edited. Lock camera on this entity
                camera.mouseAreaEnabled = false
                camera.zoom = 1
                camera.centerFreeCameraOn(entityToEdit.x + entityToEdit.width / 2,entityToEdit.y + entityToEdit.height / 2)
            }
            onReturnToLevelEditing:{//entity no longer being edited, back in general level editing. Unlock camera
                camera.mouseAreaEnabled = true
            }
    
        }
    
       CameraVPlay {
          id: camera
          maxZoom: 1
          gameWindowSize: Qt.point(gameScene.width,gameScene.height)
          entityContainer: container
          focusedObject: activeLevel.tank_player//this gets changed by my state machine to free mode when level editing 
          allowZoomWithFocus: true
          mouseArea.propagateComposedEvents: true
        }

     

    #16045

    Günther
    Felgo Team

    Hi Darren,

    I just followed up on this via email!

    Cheers,
    Günther

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support