Game works fine in emulator but not in .apk

Hi i got this code and it is working fine in the emulator but when i export it to a apk and install it on android it is only showing ‘cloud4’ someone any idea why this is ?

[code]

function createClouds()
function initcloud()
local cloud1 = {}
cloud1.imgpath = “cloud1.png”; --Set Image Path for cloud
cloud1.movementSpeed = 10000; --Determines the movement speed of cloud
table.insert(cloudTable, cloud1); --Insert cloud into cloudTable

local cloud2 = {}
cloud2.imgpath = “cloud2.png”;
cloud2.movementSpeed = 12000;
table.insert(cloudTable, cloud2);

local cloud3 = {}
cloud3.imgpath = “cloud3.png”;
cloud3.movementSpeed = 14000;
table.insert(cloudTable, cloud3);

local cloud4 = {}
cloud4.imgpath = “badcloud.png”;
cloud4.movementSpeed = 18000;
table.insert(cloudTable, cloud4);

local cloud5 = {}
cloud5.imgpath = “cloud5.png”;
cloud5.movementSpeed = 21000;
table.insert(cloudTable, cloud5);

end --END initcloud()

function getRandomcloud()
local temp = cloudTable[math.random(1, #cloudTable)] – Get a random cloud from cloudTable
local randomcloud = display.newImage(temp.imgpath); --physics.addBody(randomcloud, {isSensor = true});
if ( temp.imgpath == “badcloud.png” ) then
physics.addBody( randomcloud, “static”, { density=.1, bounce=.1, friction=.2, radius=45 } )
end
randomcloud.myName = “cloud”;
randomcloud.movementSpeed = temp.movementSpeed; – set the cloud cloudting point
randomcloud.x = math.random(10, _W);
randomcloud.y = -35;
randomcloud.rotation = math.random(0, 20); – move the cloud
cloudMove = transition.to(randomcloud, {
time = randomcloud.movementSpeed,
y = 500,
onComplete = function(self)
self.parent:remove(self);
self = nil;
end
});
end
[/code] [import]uid: 225288 topic_id: 35953 reply_id: 335953[/import]

Hi there,

When you say it’s working fine in the simulator, do you mean that it’s correctly displaying a different random cloud each time you run it?

And when you say it’s only showing cloud4 on Android, do you mean that (a) every single time you run it, cloud4 appears (i.e., it’s not random), or (b) most of the time you run it, no cloud appears at all, but when a cloud does appear, it’s cloud4 (i.e., it’s random, but only the image for cloud4 is loading correctly).

I suspect that you’re experiencing (a). And my guess is that it has to do with how the simulator vs. Android are seeding their random number generators. (It’s possible that on Android the random generator is getting the same seed every time, which is why cloud4 always appears.)

Try inserting the line [lua]math.randomseed( os.time() )[/lua] in your code, anywhere before your call to [lua]math.random[/lua], and see if it resolves the issue.

  • Andrew [import]uid: 109711 topic_id: 35953 reply_id: 142903[/import]

Hi i fixed it by removing:

[code]
function createClouds()

end
[/code] [import]uid: 225288 topic_id: 35953 reply_id: 143182[/import]

Hi there,

When you say it’s working fine in the simulator, do you mean that it’s correctly displaying a different random cloud each time you run it?

And when you say it’s only showing cloud4 on Android, do you mean that (a) every single time you run it, cloud4 appears (i.e., it’s not random), or (b) most of the time you run it, no cloud appears at all, but when a cloud does appear, it’s cloud4 (i.e., it’s random, but only the image for cloud4 is loading correctly).

I suspect that you’re experiencing (a). And my guess is that it has to do with how the simulator vs. Android are seeding their random number generators. (It’s possible that on Android the random generator is getting the same seed every time, which is why cloud4 always appears.)

Try inserting the line [lua]math.randomseed( os.time() )[/lua] in your code, anywhere before your call to [lua]math.random[/lua], and see if it resolves the issue.

  • Andrew [import]uid: 109711 topic_id: 35953 reply_id: 142903[/import]

Hi i fixed it by removing:

[code]
function createClouds()

end
[/code] [import]uid: 225288 topic_id: 35953 reply_id: 143182[/import]

Hi there,

When you say it’s working fine in the simulator, do you mean that it’s correctly displaying a different random cloud each time you run it?

And when you say it’s only showing cloud4 on Android, do you mean that (a) every single time you run it, cloud4 appears (i.e., it’s not random), or (b) most of the time you run it, no cloud appears at all, but when a cloud does appear, it’s cloud4 (i.e., it’s random, but only the image for cloud4 is loading correctly).

I suspect that you’re experiencing (a). And my guess is that it has to do with how the simulator vs. Android are seeding their random number generators. (It’s possible that on Android the random generator is getting the same seed every time, which is why cloud4 always appears.)

Try inserting the line [lua]math.randomseed( os.time() )[/lua] in your code, anywhere before your call to [lua]math.random[/lua], and see if it resolves the issue.

  • Andrew [import]uid: 109711 topic_id: 35953 reply_id: 142903[/import]

Hi i fixed it by removing:

[code]
function createClouds()

end
[/code] [import]uid: 225288 topic_id: 35953 reply_id: 143182[/import]

Hi there,

When you say it’s working fine in the simulator, do you mean that it’s correctly displaying a different random cloud each time you run it?

And when you say it’s only showing cloud4 on Android, do you mean that (a) every single time you run it, cloud4 appears (i.e., it’s not random), or (b) most of the time you run it, no cloud appears at all, but when a cloud does appear, it’s cloud4 (i.e., it’s random, but only the image for cloud4 is loading correctly).

I suspect that you’re experiencing (a). And my guess is that it has to do with how the simulator vs. Android are seeding their random number generators. (It’s possible that on Android the random generator is getting the same seed every time, which is why cloud4 always appears.)

Try inserting the line [lua]math.randomseed( os.time() )[/lua] in your code, anywhere before your call to [lua]math.random[/lua], and see if it resolves the issue.

  • Andrew [import]uid: 109711 topic_id: 35953 reply_id: 142903[/import]

Hi i fixed it by removing:

[code]
function createClouds()

end
[/code] [import]uid: 225288 topic_id: 35953 reply_id: 143182[/import]