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 › Rotate enitity with box collider

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

    Caeser

    How do I set the rotation of an entity that has a BoxCollider? I want to make sure that the BoxCollider rotates correctly with the entity.

    Also, I want to rotate the object on its center.

     

    EntityBase {
        entityType: "satellite"
        entityId: satellite
        id:satellite
    
    
        Image
        {
            id:asteroidImage
            width: 300
            height: 80
            source: "images/test satellite.png"
        }
    
        BoxCollider
        {
            id:collider
            width: 300
            height: 80
            fixedRotation: false
            
            //HOW TO SET ROTATION OF COLLIDER AND ENTITY?
    
        }
    
    
        MovementAnimation {
            target: parent
            property: "pos"
    
            velocity: Qt.point(-200, 0)
    
            // start running from the beginning
            running: true
        }
    
    
    }

     

    #6337

    Alex
    Felgo Team

    Hi,

    you can simply set the rotation property of the entity. If you want to rotate the object on it’s center, you will have to move the children of the EntityBase left and up by half their width/height, since Box2D does not support the transformOrigin property.

    EntityBase {
        entityType: "satellite"
        entityId: satellite
        id:satellite
        rotation: 45
    
        Image {
            id:asteroidImage
            width: 300
            height: 80
            x: -width/2
            y: -height/2
            source: "images/test satellite.png"
        }
    
        BoxCollider {
            id:collider
            width: 300
            height: 80
            x: -width/2
            y: -height/2
            fixedRotation: false
        }
    
        MovementAnimation {
            target: parent
            property: "pos"
    
            velocity: Qt.point(-200, 0)
    
            // start running from the beginning
            running: true
        }
    }

    Cheers, Alex

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

RSS feed for this thread

You must be logged in to reply to this topic.