Tour Preview

Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 1 Support › howto reset pressed keys on state-change

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #4477

    Thomas

    Hey,

     

    following Problem:

    while playing, i press keys and buttons to control my object to the finish-area. As soon as i reach it, i change the state and set the focus to false.

    But when i restart the level, the keys, which where pressed in the end, are still pressed, and the object is handling a “ghost”input. Same thing with the buttons.

    Also, the forces applied to the object at the end (force/torque), also get applied instantly at restart. how can i reset them?

    here is my “finished” state, if it helps anyone:

    State {
                    name: "finished"
                    PropertyChanges { target: mainMenu; visible: false}
                    PropertyChanges { target: level; visible: false}
                    PropertyChanges { target: level; levelSource:""}
                    PropertyChanges { target: finishMenu; visible: true}
                    PropertyChanges { target: buttonarea; visible: false}
                    PropertyChanges { target: scene; focus: false; }
                    PropertyChanges { target: scene; Keys.forwardTo: [scene]}
                    StateChangeScript {
                        script: {
                            Keys.enabled = false
                        }
                    }
                }

    and here is the game-state:

    State {
                    name: "game"
                    PropertyChanges {
                        target: level.space_ship
                        x: level.space_ship_x
                        y: level.space_ship_y
                    }
                    PropertyChanges { target: mainMenu; visible: false}
                    PropertyChanges { target: level; visible: true}
                    PropertyChanges { target: level; levelSource: "levels/Level02.qml"}
                    PropertyChanges { target: finishMenu; visible: false}
                    PropertyChanges { target: buttonarea; visible: true}
                    PropertyChanges { target: scene; focus: true; }
                    PropertyChanges { target: scene; Keys.forwardTo: [level.space_ship.controller]}
                    StateChangeScript {
                        script: {
                            // Pause the physicsWorld
                            //level.world.running = true
                        }
                    }
                },

     

    Hoping, someone has a solution for this… gonna check the demos once more, if i can find the solution..

     

    Cheers,

    TS

    #4482

    Thomas

    i solved one part of the problem by just calling the following script, which resets the object.

    function startGame(){
            spaceShip.x = space_ship_x
            spaceShip.y = space_ship_y
            spaceShip.controller.xAxis = 0;
            spaceShip.controller.yAxis = 0;
        }

    but still, the last impuls before finishing gets applied to the object at a restart.

    except for that, another problem is, that the game crashes, when a button is pressed at finishing and at restart, the object collides with another object.

     

    Cheers,

    TS

    #4501

    Thomas

    consider this as solved.

    Basically i used the script above and put my object into the specific level. now it works just nice, as the object also gets loaded with the level itself.

     

    Cheers,

    TS

    #4513

    Alex
    Felgo Team

    Glad you worked this out on your own! 🙂

    Cheers,

    Alex

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

RSS feed for this thread

You must be logged in to reply to this topic.