Hi guys.
I just discovered that Corona does not dynamically load physics data like Images or Sprites.
So when you do:
local physicsData = (require "obstacle").physicsData() local obstacle = display.newImageRect("images/obstacle.png", 50, 50) obstacle.x = centerX obstacle.y = centerY physics.addBody( obstacle, "static", physicsData:get(obstacle))
Corona always loads obstacle.lua, and never obstacle @2x.lua and obstacle @4x.lua
I am trying to fix this like this:
local imageSuffix = display.imageSuffix local imageSuffixVar = "obstacle" .. imageSuffix local physicsData = (require "imageSuffixVar").physicsData() local obstacle = display.newImageRect("images/obstacle.png", 50, 50) obstacle.x = centerX obstacle.y = centerY physics.addBody( obstacle, "static", physicsData:get(imageSuffixVar))
This solution does not work, I get “no field package imageSuffixVar preload” error.
How to dynamically choose external lua module?
Many thanks!
Ivan

!