Deprecated: str_replace(): Passing null to parameter #1 ($search) of type array|string is deprecated in /var/www/vhosts/gamedevstudiogame.com/httpdocs/classes/client.php on line 124

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /var/www/vhosts/gamedevstudiogame.com/httpdocs/classes/client.php on line 124
Game dev studio

Classes

Concepts

Libraries

Objects

contractor »

conversationAnswerData »

engineStatData »

issueData »

playerPlatformSpecialistData »

projectReviewConclusion »

projectReviewRemark »

randomEventData »

statusIcon »

allocateSprite

Description

Allocate or reuse a previously-allocated sprite.

Arguments

1 number slot

the slot to reuse. If none is provided, it will allocate a new one.

2 string quadName

the quad to use for the sprite.

3 number x

the X coordinate relative to the element.

4 number y

the Y coordinate relative to the element.

5 number rotation

the rotation of the sprite in radians.

6 number width

the width of the sprite. This is scaled, so do not scale this value unless your UI element class has _scaleHor set to false. This should be an unscaled width value.

7 number height

the height of the sprite. This is scaled, so do not scale this value unless your UI element class has _scaleVert set to false. This should be an unscaled width height.

8 number centerOffsetX (optional)

the X center offset of the sprite.

9 number centerOffsetY (optional)

the Y center offset of the sprite.

10 number depthOffset

the depth offset of the sprite. 0 is on the same depth level as the element itself, -0.1 will render it below the base element depth level. 0.1 will render it above the base element depth level. Generally a negative value should be used, since :draw() is called with a depth offset equivalent of 0.

Returns

1 number

slot-the allocated (or reused) sprite in the spritebatch. spriteBatchContainer-spritebatch-the spritebatch that the sprite was allocated in. spriteDataContainer-container-the container of the entire sprite data.

Example

-- taken from the Frame class extension in game/gui/gui.lua


function frame:updateSprites()	
	local poutline = self:getPanelOutlineColor()
	self:setNextSpriteColor(poutline.r, poutline.g, poutline.b, poutline.a)
	self.outlineSprite = self:allocateSprite(self.outlineSprite, "generic_1px", -1, -1, 0, self.rawW + 2, self.rawH + 2, 0, 0, -0.6)
	
	local pcol = self:getStateColor()
	self:setNextSpriteColor(pcol.r, pcol.g, pcol.b, pcol.a)
	self.bottomSprite = self:allocateSprite(self.bottomSprite, "generic_1px", 0, 0, 0, self.rawW, self.rawH, 0, 0, -0.5)

	local topSize = self._scaleVert and _US(self.fontHeight + self.offsetY) or self.fontHeight + self.offsetY
	local topColor = frame.topRectColor
	self:setNextSpriteColor(topColor.r, topColor.g, topColor.b, topColor.a)
	self.topSprite = self:allocateSprite(self.topSprite, "generic_1px", 0, 0, 0, self.rawW, topSize, 0, 0, -0.45)
end