2017년 7월 17일 월요일

Resetting sprite back to visibile


I created a game that when a ball sprite stricks a series of twenty blocks (sprites) it set the blocks' visibility to false. I need a way for the game to end when every one of the blocks' visibility is set to false.

I've trie a twenty layered if then statement, but it must be flawed because it didn't work. Any ideas?

--
Make a value procedure that returns a list of all the block sprite components, called all_blocks.

The component blocks are the last block in the drawer for each component.

Look in the Blocks pallete for the Any Sprite branch at the end.
Those are the blocks you can use with components.

To test if all 20 blocks are invisible, 

set global invisible_block_count to 0
for each block in all_blocks()
   if not(Any Sprite.Visible(block)) then
        set global invisible_block_count to 1 + global invisible_block_count 
(end if)
(end for each)
if global invisible_block_count = length of list(all_blocks()) then
   (all the blocks are invisible)



-- 
Thanks for the direction. I creatd a block, but not getting response when I call the procedure. Can you provide guidance where I need to place the call procedure to get it end game.



-- 
See this doc for examples of how to keep a list of sprites, and traverse it ...  Drag and Swap Puzzles in JSON

Your comparison was wrong.  It should check invisibility of item.

Regarding your blocks, the procedure you coded should be named check_count,
because that's what it tries to do.

See my all_sprites procedure in the doc for an example of a procedure worthy of the name all_blocks.


-- 

댓글 없음:

댓글 쓰기