简体   繁体   中英

How Can i move the hitbox of a static sprite, but also not have the object affected by gravity, in the Phaser Framework?

So I have a moveable static sprite in phaser, Basically I want the object and its hitbox to move and be collideable, while also not being affected by gravity

when i make a static body,

this.marker = this.physics.add.staticSprite(0,0, "tileSnap");

the hit box stays at (0,0) while the rest of the sprite moves

when i make it a normal physics sprite, its starts dropping due to gravity

How can I solve this?

So i found the answer in this discourse thread,

its like

platforms = this.physics.add.image(370, 430, ‘platform’).setImmovable(true)
platforms.body.setAllowGravity(false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM