Forums

OverviewV-Play 2 Support (Qt 5)How to change Behaviour on inherited sub-components › Reply To: How to change Behaviour on inherited sub-components

OverviewV-Play 2 Support (Qt 5)How to change Behaviour on inherited sub-components › Reply To: How to change Behaviour on inherited sub-components
#8642

Christian
V-Play Team

Hi Martin,

you have 2 options:

1.) Create the properties that you want to expose and use these in your animations/behaviors.

2.) Expose the whole animation with an alias.

The 2nd option is less good, because you then expose internals of the implementation.

Here is an example:

EntityBase {
    id: platform
    property alias platformImage: platformImage

    // option1 - better, because you can change the internal implementation as you just expose the API
    property int animationDuration: 3000 //default value, can be changed by the outside

    // option 2 (less good, because you expose internal implementation details to the outside)
    property alias anim: platformImage.numberAnimation

    entityType: "platform"

    width: 100
    height: 15

    Rectangle {
        id: platformImage
        anchors.fill: parent
        color: "white"

        Behavior on opacity {
            NumberAnimation {
 id: numberAnimation
property: "opacity"; duration: platform.animationDuration; easing.type: Easing.InQuart}
        }
    }
}

// then accessible like that:
Platform {
  //option 1
  animationDuration: 4000
  
  //option 2
  anim.duration: 4000
}

 

Cheers, Chris

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