Tuesday, June 7, 2022
HomeGame DevelopmentHow one can get the place of a sprite body part? -...

How one can get the place of a sprite body part? – Cocos Creator


@property({kind : SpriteComponent})
public airplane : SpriteComponent|null = null;

personal rating = 0;

replace(deltaTime: quantity) {

    let lblScore = this.node.getComponent(Label);

    **if(this.airplane.place.x > 113 && this.airplane.place.x < 130)**

    {

        this.rating += 1;

        lblScore.string = "Rating : " + this.rating;

    }

   

}

}

Within the above code when ‘airplane’ spritecomponent reaches sure place i need to replace the rating worth. however “this.airplane.place.x” doesn’t appear to work!!
what’s the motive ? how do i get its place?


Thanks for answering, however when i console “airplane.node.place.x” giving the preliminary place of airplane part although the airplane is constantly transferring.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments