Hi all,
I am porting an Android game developed in Corona SDK to Windows Phone 8 using Corona Cards.
I have already switched from ttf to bitmap fonts using this library:
https://github.com/autismuk/Font-Manager
- I am having some performance problems populating a newTableView. The same code on Android runs smoothly.
I have created a sample Visual studio project:
https://www.dropbox.com/s/zmj14nr4s4r4od2/TestTableView.rar
This is a pretty simple newTableView. In this example I have hardcoded 40 rows in the table view, but since it contains Facebook friends it can grow considerably. Simply scrolling the table view is quite chunky on Windows Phone and very fluid on Android.
-
Another performance problem I am having is downloading user avatar pictures from the internet. Here is the function I use to download the avatars and to draw it in the tableview rows:
local function drawAvatar(source,rowData,row) local avatarIco if fileExists(source…"_"…rowData.fb_user_id…".png",system.DocumentsDirectory) then avatarIco = display.newImageRect(row.rowLayer1, source…"_"…rowData.fb_user_id…".png",system.DocumentsDirectory,100,100) avatarIco.anchorX = 0 avatarIco.anchorY = 0 avatarIco.x = 10 avatarIco.y = 10 local mask = graphics.newMask( “images/mask_ico108.png” ) avatarIco:setMask( mask ) avatarIco.maskScaleX = 1 avatarIco.maskScaleY = 1 avatarIco.maskX = 0 avatarIco.maskY = 0 else avatarIco = display.newImageRect(row.rowLayer1,“images/avatar.png”,100,100) avatarIco.anchorX = 0 avatarIco.anchorY = 0 avatarIco.x = 10 avatarIco.y = 10 local mask = graphics.newMask( “images/mask_ico108.png” ) avatarIco:setMask( mask ) avatarIco.maskScaleX = 1 avatarIco.maskScaleY = 1 avatarIco.maskX = 0 avatarIco.maskY = 0 local function networkListener( event ) if ( event.isError ) then elseif ( event.phase == “began” ) then elseif ( event.phase == “ended” ) then if row ~= nil and row.rowLayer1 ~= nil then local avatarIcoLocal = display.newImageRect(row.rowLayer1,source…"_"…rowData.fb_user_id…".png",system.DocumentsDirectory,100,100); avatarIcoLocal.anchorX = 0 avatarIcoLocal.anchorY = 0 avatarIcoLocal.x = 10 avatarIcoLocal.y = 10 local mask = graphics.newMask( “images/mask_ico108.png” ) avatarIcoLocal:setMask( mask ) avatarIcoLocal.maskScaleX = 1 avatarIcoLocal.maskScaleY = 1 avatarIcoLocal.maskX = 0 avatarIcoLocal.maskY = 0 avatarIco.alpha = 0 end end end local params = {} local avatarURL if source == “FB” then avatarURL = “https://graph.facebook.com/"..rowData.fb_user_id.."/picture?height=50&type=large&width=50” elseif source == “GN” then avatarURL = “https://graph.facebook.com/"..rowData.fb_user_id.."/picture?height=50&type=large&width=50” end network.download( avatarURL, “GET”, networkListener, params, source…"_"…rowData.fb_user_id…".png", system.DocumentsDirectory ) end end
Also this code seems to be very slow when executed on windows phone, probably due to the multiple “network.download” calls.
- I have also another question regarding newTableView in general… I would like to be able to do something when a row goes off-screen (like cancelling network.download), but I have not found a way to achieve this (except doing some math on the “moved” event based on rows height scroll position). Is it possible?