Hi,
I made two Entities one is a Street which is animated to go down.
EntityBase {
id: street
entityType: "street"
property double delay: 0
property int variationDistance: 70
MultiResolutionImage{
id: streetpic
source:"../../assets/street.png"
anchors.fill: parent
}
MovementAnimation {
id: animation
target: parent
property: "y"
velocity: +150
running: true
maxPropertyValue: gameWindow.height
onLimitReached: {
reset()
}
}
...
When I create my Car Entity which slides from left to right or otherwise like this:
Street{
id: str2
width: crossstreet.width + 400
height: crossstreet.height/5
variationDistance: 210
Car{
id: car2
width: str.height
height: str.height
randSite: Math.random()<0.5 ? 0 : 1
}
}
everthing works fine. This means my car inherits the movement animation from the street. It actually is positioned right on the street.
But I want to create the Car dynamically and random like this:
Timer {
id: timer
interval: Math.random()*3000 + 2000
running: true // start running from the beginning, when the scene is loaded
repeat: true // otherwise restart wont work
onTriggered: {
var newEntityProperties = {
width: str.height,
height: str.height,
randSite: Math.random()<0.5 ? 0 : 1,
}
entityManager.createEntityFromUrlWithProperties(Qt.resolvedUrl("../Entities/Car.qml"),
newEntityProperties);
// recalculate new interval between 2000 and 5000ms
interval = Math.random()*3000 + 2000
// restart the timer
timer.restart()
}
}
Problem is I don’t know how to inherit the movement animation from the street like before. The cars just don’t end up on the street.
Any Idea how I could solve this problem?
Thx