开发者

Coronasdk: About Factory Pattern and Corona Forum

开发者 https://www.devze.com 2023-03-31 01:16 出处:网络
I am new to corona and I tried to post in forum but I do not how. I could not find button or link liked \"new thread\", what should I do?

I am new to corona and I tried to post in forum but I do not how. I could not find button or link liked "new thread", what should I do?

I also have a question about Factory pattern in corona. I tried to make myImage.lua which works liked factory function.

--in myImage.lua (I created global function)

function a(path)

  local b = display.newImage(path)

(another setting)

  return b;

end
开发者_StackOverflow社区

I found that when I call this function in main.lua, the function give me just one image no matter how many time I called function. So I guessed that this is not factory function. I wonder that is there somehow that I can create function which return new item+different item(not reference the existed one) every times that I called


Try adding it to a display group. That should retain the images.

--Global variable:
local images = display.newGroup()

function a(path)

  local b = display.newImage(path)
  (another setting)
  images:insert(b)

end

Oh, and you have to buy the thing before you can use the forums.

0

精彩评论

暂无评论...
验证码 换一张
取 消