Updated for Gideros - Inventory System 1
About two years ago there was an article posted on the HowTo site around July 16th this article can be found here. It talked about how one can implement an inventory system in their game.
This article was composed of three articles which can be found at these links
In the first part, we talk about the theory behind Inventory Management and we have a small piece of code that demonstrates how to position the items. The code which was written for CoronaSDK is as follows
local function displayIconOnScreen(slotNo) local imageName = items[slotNo] -- this is our icon filename rowNo = math.round(slotNo / iconsAcross) columnNo = (slotNo % iconsAcross) local xPos = columnNo * iconWidth local yPos = rowNo * iconHeight local image = display.newImage(imageName) image:setReferencePoint(display.TopLeftReferencePoint) image.x = offsetX + xPos image.y = offsetY + yPos end
The same code can be adapted for Gideros Studio as
local function displayIconOnScreen(slotNo) local imageName = items[slotNo] -- this is our icon filename rowNo = math.round(slotNo / iconsAcross) columnNo = (slotNo % iconsAcross) local xPos = columnNo * iconWidth local yPos = rowNo * iconHeight local image = Bitmap.new(Texture.new(imageName)) stage:addChild(image) image:setPosition(offsetX + xPos, offsetY + yPos) end
With just that little bit of change the code is now updated for use with Gideros Studio.
Comments
Post a Comment