
Or by modifying cropRect property directly and then calling updateCrop. The Game Object width and height properties will be adjusted accordingly.Ĭropping takes place from the top-left and can be modified in real-time either by providing an updated rectangle object to this method, Setting a crop rectangle modifies the core texture frame. Gameobjects/components/PhysicsBody.js ( Line 91)Ĭrop allows you to crop the texture being used to display this Game Object. If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics. So the physics body is centered on the Game Object. Important: Enabling a Game Object for P2 or Ninja physics will automatically set its anchor property to 0.5, You can alternatively call (object), or add this Game Object to a physics enabled Group. To enable this Game Object for physics you need to call (object, system) where object is this objectĪnd system is the Physics system you are using. Once a Game Object is enabled for physics you access all associatedīy default Game Objects won't add themselves to any physics system and their body property will be null. If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.īody is the Game Objects physics body.

It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. This is the image or texture used by the Sprite during rendering. The y coordinate (in world space) to position the Sprite at. The x coordinate (in world space) to position the Sprite at.

Parameters NameĪ reference to the currently running game. They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input),Įvents (via Sprite.events), animation (via Sprite.animations), camera culling and more. Sprites are the lifeblood of your game, used for nearly everything visual.Īt its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas.
