code doesn't execute in logical sequence

NOTE This code is in a function that is a listener for display object: “playerPiece”. It’s is called when playerPiece gets an onTouch event when event.phase == “ended”

Line 1 just snaps the display object back to it’s original position after it was moved.
But the actual SNAP BACK doesn’t occur until after the pause code has finished executing. What the heck is going on?

playerPiece.x=playerPiece.orgX; playerPiece.y=playerPiece.orgY  
  
-- Pause a little while  
local t1 = os.clock()  
local t2 = t1  
while os.difftime(t2, t1) \< 10 do -- pause before swapping player  
 t2 = os.clock()  
end  

[import]uid: 295 topic_id: 1499 reply_id: 301499[/import]

Every frame all events that are active are called. I don’t now if the graphics are drawn before or after that. But it doesn’t really matter. First all functions have to done running before you can see the result of your position change. Why do you have a pause here? [import]uid: 5712 topic_id: 1499 reply_id: 4212[/import]

I put the pause in there so a sound file that I start up has time to finish playing before the next statements are executed. That’s how I found the sequence problem. I didn’t notice it before I added the pause/sound file because the playerPiece was popping back to it’s original position at the correct time befor the following statements were executed. [import]uid: 295 topic_id: 1499 reply_id: 4213[/import]

So you want to play a sfx that is related to the position change. Then I would use a transition.to method to chnage the position. this way you can use it’s onComplete handler to play the sound when the transition is done. [import]uid: 5712 topic_id: 1499 reply_id: 4214[/import]

Never thought about that. Thanks. Only thin is it’s exactly opposite of what I wan to do. The sequence I want is:

  1. From staging area put a player piece on game board.
  2. Snap the player piece back to its original position in staging area.
  3. Play a two-second force field sound.
  4. The force field sound completes.
  5. Slide in the next player panel WITH a servo sound. (the slide and servo sound lasts about .5 sec.) [import]uid: 295 topic_id: 1499 reply_id: 4215[/import]

I’m starting to think that Corona’s event/listener/sound/timer/thread handling are useless in some cases because of lack of more granular ways to control them. [import]uid: 295 topic_id: 1499 reply_id: 4216[/import]

I wouldn’t say that. It is how you manage your states inside your game. [import]uid: 5712 topic_id: 1499 reply_id: 4218[/import]

Well my sample of what i want to do is pretty simple. If something so simple can’t be accomplished than I think the problem is with the environment.
Another thing about my example and what is really happening makes no sense. The 2nd sound (servo) executes before the 1st sound. is there some kind of queue for sounds that we have no control over with Corona but which is expected with Obj-C?

20 years ago, AMOS Basic or Blitz Basic on the Amiga had better control with such things.

Sorry. I’m just a little pissed off from working all day on something that just makes no sense. [import]uid: 295 topic_id: 1499 reply_id: 4219[/import]

Dan,

AMOS, I loved it. Same as STOS. And so Blitz3D, BlitzMax and others. But that’s a big difference, these a
prodcedual languages. Don’t try to work with a procedual approach in an event driven environment like Corona.

Without seeying some of your code it is difficult to make suggestions.

Cheers
Michael Hartlef

http://www.whiteskygames.com
http://www.twitter.com/mhartlef [import]uid: 5712 topic_id: 1499 reply_id: 4220[/import]

Maybe my onTouch routine which is the main event driven code is too long and that’s why my code isn’t executing in order. I wonder if playEventSound spawns an overriding thread that cancels the previous call to playEventSound if they are called to close together in time.
I’m also wondering if the playEventSound uses a normal queue (FILO) instead of FIFO. [import]uid: 295 topic_id: 1499 reply_id: 4225[/import]

I wonder why I’m getting no help on this. Maybe it is known that my problem can’t be solved [import]uid: 295 topic_id: 1499 reply_id: 4233[/import]

I’ll have our QE engineers look into this …

Is there a way you can send us code to test against (assets as well) at support AT anscamobile dot com?

Carlos [import]uid: 24 topic_id: 1499 reply_id: 4234[/import]

What format sound(s) were you playing? Some sounds have a lag because of decoding.

Can you use a sound event completion listener?
http://developer.anscamobile.com/content/multimedia-features

[import]uid: 54 topic_id: 1499 reply_id: 4236[/import]

Thanks,

I am using .caf sound files. Also I don’t think media.playEventSound( “beep.caf”, onComplete ) would work cause that’d just call whatever listener I registered with it while the main code would continue to execute.

I’d have to move most of my code to the sound event completion listener than that wold be designing the whole game AROUND the sound. I don’t want to do that. And it wouldn’t seem right to do it that way.

Actually the the whole project with a detailed explanation should be in ANSCA’s support inbox now. [import]uid: 295 topic_id: 1499 reply_id: 4237[/import]

Thanks,

The code and assets should be n your inbox now. Along with a detailed explanation. [import]uid: 295 topic_id: 1499 reply_id: 4238[/import]

(well forget it :slight_smile: [import]uid: 6928 topic_id: 1499 reply_id: 4239[/import]

Dan,

I said without seeing code it is impossible to help you there. Then you come up with

“I wonder why I’m getting no help on this.”

For sure you have a strange way in for asking for help. [import]uid: 5712 topic_id: 1499 reply_id: 4240[/import]

Sorry.

I thought that you had helped as much as you could with the information that you had. And I took your statement wrong and didn’t see it as an offer. I thought that you meant it literally: “Sorry I’ve helped as much as I could but can’t help more than that because I don’t know the details of what your doing.”

And I also thought my problem was due to Corona Idiosyncrasies rather than due to my inability to code properly, and that the only people who could help me would be the ANSCA gurus.

Therefore I meant that comment for the formal ANSCA gurus. I should have shown that in the comment.
I’m very sorry about that.

Actually everybody is very helpful here and I was surprised that ANSCA didn’t jump in right away.

Anyway, as you can see in the posts, the ANSCA guys have come to my rescue.

Regards

[import]uid: 295 topic_id: 1499 reply_id: 4242[/import]

I (and I guess Mike too) think that your problem is one of understanding what happens instead of an actual bug or problem with Lua/Corona.

Mike wrote: “Without seeying some of your code it is difficult to make suggestions.” … can’t be more clear can’t it?

Anyway… hope you get your problem solved by the Ansca guys now! [import]uid: 6928 topic_id: 1499 reply_id: 4243[/import]

Thanks, I’ll let you know what the ANSCA gurus find out. Actually I hope it’s me instead of a problem/bug in Corona/Lua because I really like the system (if it works properly). [import]uid: 295 topic_id: 1499 reply_id: 4244[/import]