Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to remove a black stripe on my map?
Started by suprasumomario Mar 16 2015 06:00 AM

1 reply to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

suprasumomario

[GLOBAL: userInfoPane.html]
suprasumomario
  • Observer

  • 12 posts
  • Corona SDK

I'm getting a weird issue: My map consist to show 15x10 blocks on the screen at time (each block has 32x32 pixels, then the resolution needed is 480x320).

When I try to render the map, something happens, a black stripe is created on the bottom of the screen (some as iPad Mini the stripe is on right side), hiding the entire last row.

Example:

corona_issue.jpg

My config:
 

width = 320,
height = 480,
scale = "zoom",
fps = 30

The code:
 

mte.loadTileSet("Tiles", "Tiles.png")
mte.loadMap("maps/maptest.tmx")

local camera = mte.setCamera({locX = 1, locY = 1, scale = 1})
mte.constrainCamera()

I noticed some phone viewers like iPhone 4 (640x960), Kindle Fire HD 7' (800x1280) show the map correctly. What can I do to fit the map correctly on the screen?

 

Thanks!



[TOPIC: post.html]
#2

suprasumomario

[GLOBAL: userInfoPane.html]
suprasumomario
  • Observer

  • 12 posts
  • Corona SDK

I figured how to fix that just trying to get the aspect ratio and calculate how I need properly to scale X and Y axis regardless of mobile's display.
 
Like I said before, I always want to exhibit 15x10 blocks and fit all of them at same time on screen:
 
Considering each block has 32 x 32 pixels I can do it:
 

 local facScaleX = 1
 local facScaleY = 1
 local blockSizeX = display.actualContentWidth / 15
 local blockSizeY = display.actualContentHeight / 10
 
 if blockSizeX ~= 32 then
  facScaleX = display.actualContentWidth / 480
 end
 
 if blockSizeY ~= 32 then
  facScaleY = display.actualContentHeight / 320
 end
 
 local camera = mte.setCamera({locX = 1, locY = 1, scaleX = facScaleX, scaleY = facScaleY})
 mte.constrainCamera()

This code works nicely if you set your project for "zoomEven" scale factor on config.lua.

But PLEASE I feel that as workaround so I'd like to see another solution and alternatives, maybe something that Works better, I don't know.




[topic_controls]
[/topic_controls]