Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Lua 

Problem looping and switching between sprites

Basically I have two images of a character to make it look like it's walking. I simply want him to walk across the screen.

My code uses the Corona SDK and since some of you might not be familiar with that, I'll just simplify it:
Code
for i = 0, 150, 2

   if sprite = 1 then
  move sprite over by current position + i
  sprite = 2
  pause for 500 miliseconds()
   end

   if sprite = 2 then
  move sprite over by current position + i
  sprite = 1
  pause for 500 miliseconds()
   end

end

When I run it, the character instantly moves to the ending position, only 1 frame change is noticeable, and all the "pauses" happen AFTER the loop is finished (when I debug, the loop starts, both the if statements are executed, and then it loops 74 more times without any if statements being executed. Then after looping is complete, it executes 2 pauses.)

I have no idea why this would happen and would appreciate any suggestions. Thanks!


Possibly Related Threads...
Thread / Author Replies Views Last Post
by FolksJan 27, 2017 04:06 PM 2 110 Jan 27, 2017 04:06 PM
Last Post: Folks
by FυcĸleѕѕApr 24, 2015 04:37 AM 1 108 Apr 24, 2015 04:37 AM
Last Post: gecco
[Help] by Aur3xisNov 9, 2014 04:17 AM 6 107 Nov 9, 2014 04:17 AM
Last Post: Aur3xis