Can't correctly assign new values to display objects with large positional values

This is a pretty obscure bug that’s not likely to come up much, but I discovered this today. It’s very easy to duplicate (I’m using build 894 for Windows), so I thought it would be worth reporting.

Here’s the code:

local test = display.newRect(50, 50, 10, 10)  
test.x = 2000000000  
test.x = 50  
print (test.x)  

Instead of printing 50, it prints 0. If we change the code to:

local test = display.newRect(50, 50, 10, 10)  
test.x = 2000000000  
test.x = 50  
test.x = 50  
print (test.x)  

… the correct value now gets printed. [import]uid: 13621 topic_id: 31456 reply_id: 331456[/import]

Sure it is a strange situation and as you said the 2nd chunk of code you posted does work as expected. However, I`ve found that if you declare your object (the rect in your case) into a Lua table, well, it does work as expected in your 1st posted code, look below:

[lua]local test = { display.newRect(50, 50, 10, 10) };
test.x = 2000000000;
print (test.x); – print 2000000000
test.x = 50;
print (test.x); – print 50[/lua]

PS: Even it working this way, this still is a weird thing I agree.


Rodrigo. [import]uid: 89165 topic_id: 31456 reply_id: 125724[/import]

Sure it is a strange situation and as you said the 2nd chunk of code you posted does work as expected. However, I`ve found that if you declare your object (the rect in your case) into a Lua table, well, it does work as expected in your 1st posted code, look below:

[lua]local test = { display.newRect(50, 50, 10, 10) };
test.x = 2000000000;
print (test.x); – print 2000000000
test.x = 50;
print (test.x); – print 50[/lua]

PS: Even it working this way, this still is a weird thing I agree.


Rodrigo. [import]uid: 89165 topic_id: 31456 reply_id: 125724[/import]