It looks like you're new here. If you want to get involved, click one of these buttons!
ScreenSize = Core.class() function ScreenSize:init() self.widthDif = math.ceil(application:getLogicalTranslateX() / application:getLogicalScaleX()) self.heightDif = math.ceil(application:getLogicalTranslateY() / application:getLogicalScaleY()) self.screenHeight = self.heightDif + application:getContentHeight() self.screenWidth = self.widthDif + application:getContentWidth() end function ScreenSize:getMinX() return -self.widthDif end function ScreenSize:getMinY() return -self.heightDif end function ScreenSize:getMaxX() return self.screenWidth end function ScreenSize:getMaxY() return self.screenHeight end function ScreenSize:getMinXY() return self:getMinX(), self:getMinY() end function ScreenSize:getMaxXY() return self:getMaxX(), self:getMaxY() end |
s = ScreenSize.new() x,y = s:getMinXY() w,h = s:getMaxXY() local tlBox = Shape.new() tlBox:setFillStyle(Shape.SOLID, 0xff0000, 0.5) tlBox:beginPath() tlBox:moveTo(x, y) tlBox:lineTo(x+100, y) tlBox:lineTo(x+100, y+100) tlBox:lineTo(x, y+100) tlBox:lineTo(x, y) tlBox:endPath() stage:addChild(tlBox) local trBox = Shape.new() trBox:setFillStyle(Shape.SOLID, 0xff0000, 0.5) trBox:beginPath() trBox:moveTo(w, y) trBox:lineTo(w, y+100) trBox:lineTo(w-100, y+100) trBox:lineTo(w-100, y) trBox:lineTo(w, y) trBox:endPath() stage:addChild(trBox) local blBox = Shape.new() blBox:setFillStyle(Shape.SOLID, 0xff0000, 0.5) blBox:beginPath() blBox:moveTo(x, h) blBox:lineTo(x+100, h) blBox:lineTo(x+100, h-100) blBox:lineTo(x, h-100) blBox:lineTo(x, h) blBox:endPath() stage:addChild(blBox) local brBox = Shape.new() brBox:setFillStyle(Shape.SOLID, 0xff0000, 0.5) brBox:beginPath() brBox:moveTo(w, h) brBox:lineTo(w, h-100) brBox:lineTo(w-100, h-100) brBox:lineTo(w-100, h) brBox:lineTo(w, h) brBox:endPath() stage:addChild(brBox) local middBox = Shape.new() middBox:setFillStyle(Shape.SOLID, 0x00ff00, 0.5) middBox:beginPath() middBox:moveTo(x+50, y+50) middBox:lineTo(w-50, y+50) middBox:lineTo(w-50, h-50) middBox:lineTo(x+50, h-50) middBox:lineTo(x+50, y+50) middBox:endPath() stage:addChild(middBox) |
Likes: vitalitymobile, ar2rsawseen, chipster123, Daimyo21
Comments
http://developer.intoitgames.com/gideros-display
There are Display.TOP/BOTTOM/RIGHT/LEFT/etc. static fields in my lib... just check out the front docs page.
You guys might find both me and @kredor7 's code useful. Happy coding
https://play.google.com/store/apps/developer?id=Into-It+Games
http://appstore.com/LidiaMaximova