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
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:
From staging area put a player piece on game board.
Snap the player piece back to its original position in staging area.
Play a two-second force field sound.
The force field sound completes.
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]
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]
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.
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 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]
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.
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]