Hi,
In a strategic game when i launch a recursive function (computer play) all is blocked (sprites, keyboard, …).
When the move is founded all is unblocked…
Any idea to resolve this problem plz ?
Thx for your help
Hi,
In a strategic game when i launch a recursive function (computer play) all is blocked (sprites, keyboard, …).
When the move is founded all is unblocked…
Any idea to resolve this problem plz ?
Thx for your help
Without seeing your code I would just say
local gameBlocked = true
then when your move is found say
gameBlocked = false
then in your loop say
if (gameBlocked == true) then //or false depending on what you are doing
//go ahead and allow moving etc. or block it.
end
Thx but i have already test that and the code is only unblocked when the recursive function is finished.
There is a command for give time process but i don’t remember it.
damn a command for time process would come in handy, but I have never heard of it…
I always end up using a timer and a global CanClick function
and to unblock sprites animation ?
Maybe recursive function is blocking it all? Can you post an example?
Recursive function is correct because when the move is founded sprites are unblocked.
I didn’t assume it was wrong in the first place. I only want to know, if it blocks all the process until the recursion is completed like a loop that executes 1000000 times.
It’s really hard to find solutions without an example by the way.
recurse function found move in 1, 2, 5, 9, 12, 16, 22, 30, 60 seconds (it’s the difficulty level of game)
There is a sprite (an animate wheel for thinking) blocked during the recurse function execution.
Otherwise the game works fine
i can also remove sprite but… it’s not a good solution
Download my puzzle game and tell me if that is what you are talking about with moves being blocked etc. if so then I can just send you over the code that does just that.
https://play.google.com/store/apps/details?id=the.billyblob.saga
In a nutshell you have to move blocks out of the way if they are in fact blocking the way and/or the arrow on the block is moving in a different direction then you cannot move.
But like bgm said it is really hard to help you out without some kind of example or better explanation
Sorry just saw your post while i posted.
If
If all you want to do is turn off the animated wheel or check what to do when it is done couldn’t you just run a sprite finished event and check if it is still blocked if not run the animation again?
local function spriteListener( event ) if (event.phase == "ended") then if (gameStillBlocked == true) then spriteObj:play() end end end spriteObj:addEventListener( "sprite", spriteListener )
That way it “only” plays when it is checking for moves.
Thx Christopher but i have already try this solution and no change
Well… i remove the sprite lol
If you are using an image sheet or have the sprite loaded and hidden “as a temp image” then if you add/remove it should already be in memory and you wont take the load hit.
Your game probably has too many moves, and that freezes the game since you are searching through every single move IN A SINGLE FRAME - which is what a recursive function does.
If that’s the case, you should think of structuring your game moves differently, for efficient lookup.
A binary search tree perhaps?
Without seeing your code I would just say
local gameBlocked = true
then when your move is found say
gameBlocked = false
then in your loop say
if (gameBlocked == true) then //or false depending on what you are doing
//go ahead and allow moving etc. or block it.
end
Thx but i have already test that and the code is only unblocked when the recursive function is finished.
There is a command for give time process but i don’t remember it.
damn a command for time process would come in handy, but I have never heard of it…
I always end up using a timer and a global CanClick function
and to unblock sprites animation ?
Maybe recursive function is blocking it all? Can you post an example?