Forums

OverviewV-Play 1 SupportLevelEditor: cant drag&drop/place BuildEntityButton › Reply To: LevelEditor: cant drag&drop/place BuildEntityButton

OverviewV-Play 1 SupportLevelEditor: cant drag&drop/place BuildEntityButton › Reply To: LevelEditor: cant drag&drop/place BuildEntityButton
#6429

V-Play User

Thx for your input chris.

1) I moved the ItemEditor from LevelEditorScene.qml to main.qml:

...
    LevelEditor {
        id: levelEditor
        applicationJSONLevelsDirectory: "JSONLevels/"
        toRemoveEntityTypes: [ "platform", "platformGoal", "stars", "obstacle" ]
        toStoreEntityTypes: [ "platform", "platformGoal", "stars", "obstacle" ]
        Component.onCompleted: {
            loadAllLevelsFromStorageLocation(applicationJSONLevelsLocation)
        }
    }

    ItemEditor {
        id: itemEditor
        opacity: 0.8
        z:1
        visible: window.state === "levelEditing" && scene.state  !== "playing"
    }
...

2) changed the BuildEntityButton –> used a Image instead of Platform
LevelEditorScene.qml:

import QtQuick 1.1
import VPlay 1.0
import "./base"
import "./entities"

SceneBase {
    id: scene
    width: scene.width
    height: scene.height

    onBackPressed: {
        window.state = "main"
    }

    // this allows faster navigation through the scenes by pressing the Enter(=Return) key
    Keys.onReturnPressed: {
        window.state = "main"
    }

    Component.onCompleted: {
        scene.state = "levelEditing"
    }

    Column {
        anchors.right: parent.right

        spacing: 5

        MenuButton {
            text: scene.state === "playing" ? qsTr("Level Mode") : qsTr("Game Mode")
            onClicked: {
                if(text === "Level Mode")
                    scene.state = "levelEditing"
                else
                    scene.state = "playing"
            }

            anchors.right: parent.right
        }
        MenuButton {
            text: (itemEditor.visible ? qsTr("hide") : qsTr("show"))+" "+qsTr("ItemEditor")
            onClicked: itemEditor.visible = !itemEditor.visible
            anchors.right: parent.right
        }

        SimpleButton {
            text: "New Level"
            onClicked: levelEditor.createNewLevel()
            height: 20
        }

        SimpleButton{
            text: "Save Level"
            onClicked: nativeUtils.displayTextInput("Enter level name", "", levelEditor.currentLevelName)
            height: 20
            Connections{
                target: nativeUtils
                onTextInputFinished:{
                    if(accepted){
                        levelEditor.saveCurrentLevel({levelMetaData: {levelName: enteredText, "storageLocation": "applicationJSON"}})
                        levelEditor.exportLevelAsFile(enteredText)
                    }
                }
            }
        }

        SimpleButton {
            text: "JSON Levels"
            height: 20
            onClicked: {
                levelEditor.loadAllLevelsFromStorageLocation(levelEditor.applicationJSONLevelsLocation)
                //levelSelectionList.levelMetaDataArray = levelEditor.applicationJSONLevelsLocation
                levelSelectionListContainer.visible = true
            }
        }
        BuildEntityButton {
            visible: scene.state === "levelEditing"
            toCreateEntityType: Qt.resolvedUrl("entities/Obstacle.qml")
            creationProperties:{"width":50, "height":50}
            width: 50
            height: 50
            anchors.right: parent.right

            // the obstacle is just a grey entity, we can customize the look of the button here
            Rectangle {
                color: "grey"
                anchors.fill: parent
            }
        }
    }

    Rectangle {
        id: levelSelectionListContainer
        anchors.horizontalCenter: parent.horizontalCenter
        y: 40
        width: 100
        height: 100
        visible: false
        color: "black"

        LevelSelectionList {
            id: levelSelectionList
            // at the beginning it is invisible, only gets visible after a click on the Levels button
            z: 4
            width: 100
            height: 100
            anchors.horizontalCenter: parent.horizontalCenter
            // this connects the stored levels from the player with the level list
            levelMetaDataArray: levelEditor.applicationJSONLevels
            onLevelSelected: {
                console.debug(levelData)
                levelEditor.loadSingleLevel(levelData)
                // make invisible afterwards
                levelSelectionListContainer.visible = false
            }
        }
    }

    // HUD bottom, for adding new platforms and stars
    Rectangle {
        id: hudBottom
        visible: window.state === "levelEditing" && scene.state !== "playing"
        width: gameWindowAnchorItem.width
        height: 40
        anchors.bottom: parent.bottom
        anchors.right: parent.right
        color: "grey"
        Row {
            id:hudBottomRow
            //            columns: 3
            anchors.right: parent.right
            Column {
                BuildEntityButton {
                    id: hudBottomButton1
                    visible: hudBottom.visible
                    toCreateEntityType: Qt.resolvedUrl("entities/Platform.qml")
                    creationProperties: { "width":50, "height":8, "z":33}
                    z: 1
                    width: 60
                    height: 20

                    // one Platform to add
                    Image {
                        width: 50
                        height: 8
                        anchors.centerIn: parent
                        source: "img/platform.png"
                    }
                }
                MenuText {
                    text: qsTr("Platform")
                    font.pixelSize: 12
                }
            }
            Column {
                BuildEntityButton {
                    id: hudBottomButton2
                    visible: hudBottom.visible
                    toCreateEntityType: Qt.resolvedUrl("entities/PlatformGoal.qml")
                    creationProperties: { "width":100, "height":8, "z":33}
                    z: 1
                    width: 110
                    height: 20

                    // one PlatformGoal to add
                    Image {
                        width: 100
                        height: 8
                        anchors.centerIn: parent
                        source: "img/platform.png"
                    }
                }
                MenuText {
                    text: qsTr("Goal Platform")
                    font.pixelSize: 12
                }
            }
            Column {
                BuildEntityButton {
                    id: hudBottomButton3
                    visible: hudBottom.visible
                    toCreateEntityType: Qt.resolvedUrl("entities/Star.qml")
                    creationProperties: { "width":11, "height":10, "z":33}
                    z: 1
                    width: 30
                    height: 20

                    // one Star to add
                    Image {
                        width: 11
                        height: 10
                        anchors.centerIn: parent
                        source: "img/star.png"
                    }
                }
                MenuText {
                    text: qsTr("Star")
                    font.pixelSize: 12
                }
            }
        }
    }
}

and if i drag a Platform now, i get this Output:

BuildEntityButton: button MouseArea pressed, start dragging entity
Box2DBody: calling sychronize after active got set to true 
BuildEntityButton: entity got pressed: Platform_QMLTYPE_98(0x110f2e990, "platform_2") , for creationType: file:///Users/xxxxx.app/Contents/Resources/qml/entities/Platform.qml
pos of createdEntity: 316.5 221
BuildEntityButton: button MouseArea released
EntityBaseDraggable: entityReleased position: 233.5 126.5 snapped position: 240 128
entity got released, create it at the position if allowed to build
EntityManager: createEntityFromUrl: file:///Users/xxxxx.app/Contents/Resources/qml/entities/Platform.qml
EntityBaseDraggable: loaded buildCollider with colliderType box
EntityManager: adding a component for the entityType ' platform ' to the entityTypeAndVariationTypeToComponentMap
EntityManager: entity created with entityId: platform_29
GameWindow: creating cocos item in cocosWrapper triggered by JavaScript code explicitly: Platform_QMLTYPE_98(0x1110f8f10, "platform_29")

I tried it with and without creationProperties -> nothing.

And i wont get this red Rectangle if i drag, like in the movie in my second post.

Do you have any idea or solution?

 

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