{"id":93,"date":"2024-06-07T08:38:36","date_gmt":"2024-06-07T11:38:36","guid":{"rendered":"http:\/\/pplay.local\/?page_id=93"},"modified":"2024-06-20T20:03:23","modified_gmt":"2024-06-20T23:03:23","slug":"animation","status":"publish","type":"page","link":"http:\/\/www2.ic.uff.br\/pplay\/documentacao\/animation\/","title":{"rendered":"Animation"},"content":{"rendered":"\n<p>Cria uma anima\u00e7\u00e3o composta por N frames (o&nbsp;frame inicial padr\u00e3o \u00e9 0).&nbsp;O m\u00e9todo&nbsp;set_sequence_time(ms)&nbsp;deve ser chamado antes de tentar rodar a&nbsp;<strong>Animation<\/strong>.&nbsp;O tamanho de cada frame \u00e9 calculado baseado no tamanho da imagem e no total de frames desejado.<\/p>\n\n\n\n<p>Exemplo:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"123\" src=\"http:\/\/www2.ic.uff.br\/pplay\/wp-content\/uploads\/2024\/06\/sprite-animation.webp\" alt=\"\" class=\"wp-image-496\" srcset=\"http:\/\/www2.ic.uff.br\/pplay\/wp-content\/uploads\/2024\/06\/sprite-animation.webp 621w, http:\/\/www2.ic.uff.br\/pplay\/wp-content\/uploads\/2024\/06\/sprite-animation-300x59.webp 300w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/figure><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Fun\u00e7\u00f5es da Classe<\/h2>\n\n\n\n<p><strong>Animation(image_file, total_frames, loop=True)<\/strong><br>Cria uma anima\u00e7\u00e3o a partir do image_file, com total_frames.<\/p>\n\n\n\n<p><strong>set_sequence(initial_frame, final_frame, loop=True)<\/strong><br>Define o frame inicial e o frame final da sequ\u00eancia de frames da anima\u00e7\u00e3o, utilizando&nbsp;<em>initial_frame<\/em>&nbsp;e&nbsp;<em>final_frame<\/em>, respectivamente. Define tamb\u00e9m pelo&nbsp;<em>booleanloop<\/em>&nbsp;se a&nbsp;<strong>Animation<\/strong>&nbsp;deve ficar repetindo infinitamente.<\/p>\n\n\n\n<p><strong>set_sequence_time(initial_frame, final_frame, total_duration, loop=True)<\/strong><br>Define o frame inicial e o frame final da sequ\u00eancia de frames da&nbsp;<strong>Animation<\/strong>, utilizando&nbsp;<em>initial_frame<\/em>&nbsp;e&nbsp;<em>final_frame<\/em>, respectivamente. Define em&nbsp;<em>total_duration<\/em>&nbsp;o tempo que a&nbsp;<em>Animation<\/em>&nbsp;deve demorar para efetuar um&nbsp;<em>loop<\/em>&nbsp;completo (valor em milissegundos). Define tamb\u00e9m pelo&nbsp;<em>booleanloop<\/em>&nbsp;se a&nbsp;<em>Animation<\/em>&nbsp;deve ficar repetindo infinitamente.<\/p>\n\n\n\n<p><strong>set_total_duration(time_ms)<\/strong><br>Define o tempo (em milissegundos) que a&nbsp;<strong>Animation<\/strong>&nbsp;demora para efetuar um&nbsp;<em>loop<\/em>&nbsp;completo.<\/p>\n\n\n\n<p><strong>update()<\/strong><br>Realiza o controle de anima\u00e7\u00e3o da&nbsp;<strong>Animation<\/strong>. Deve ser chamada a cada game&nbsp;<em>loop<\/em>.<\/p>\n\n\n\n<p><strong>draw()<\/strong><br>Desenha o atual frame da&nbsp;<strong>Animation<\/strong>&nbsp;o na janela.<\/p>\n\n\n\n<p><strong>stop()<\/strong><br>Para a execu\u00e7\u00e3o e coloca o frame inicial como atual.<\/p>\n\n\n\n<p><strong>play()<\/strong><br>Inicia a anima\u00e7\u00e3o.<\/p>\n\n\n\n<p><strong>pause()<\/strong><br>Pausa a anima\u00e7\u00e3o no frame atual.<\/p>\n\n\n\n<p><strong>is_playing()<\/strong><br>Retorna um&nbsp;<em>boolean<\/em>&nbsp;que diz se a&nbsp;<strong>Animation<\/strong>&nbsp;est\u00e1 sendo executada.<\/p>\n\n\n\n<p><strong>is_looping()<\/strong><br>Retorna um&nbsp;<em>boolean<\/em>&nbsp;que diz se a&nbsp;<strong>Animation<\/strong>&nbsp;est\u00e1 em&nbsp;<em>loop<\/em>.<\/p>\n\n\n\n<p><strong>set_loop(loop)<\/strong><br>Define por um&nbsp;<em>boolean<\/em>&nbsp;se a&nbsp;<strong>Animation<\/strong>&nbsp;deve ser executada em&nbsp;<em>loop<\/em>.<\/p>\n\n\n\n<p><strong>hide()<\/strong><br>N\u00e3o permite que a&nbsp;<strong>Animation<\/strong>&nbsp;apare\u00e7a na tela.<\/p>\n\n\n\n<p><strong>unhide()<\/strong><br>Torna a&nbsp;<strong>Animation<\/strong>&nbsp;desenh\u00e1vel novamente.<\/p>\n\n\n\n<p><strong>get_total_duration()<\/strong><br>Retorna a dura\u00e7\u00e3o total da&nbsp;<strong>Animation<\/strong>&nbsp;como&nbsp;<em>int<\/em>&nbsp;em&nbsp;<em>milissegundos<\/em>.<\/p>\n\n\n\n<p><strong>set_initial_frame(frame)<\/strong><br>Define o n\u00famero do frame que passar\u00e1 a ser considerado o inicial.<\/p>\n\n\n\n<p><strong>get_initial_frame()<\/strong><br>Retorna um&nbsp;<em>int<\/em>&nbsp;com o n\u00famero do frame inicial.<\/p>\n\n\n\n<p><strong>set_final_frame(frame)<\/strong><br>Define o n\u00famero do frame que passar\u00e1 a ser considerado o final.<\/p>\n\n\n\n<p><strong>get_final_frame()<\/strong><br>Retorna um&nbsp;<em>int<\/em>&nbsp;com o n\u00famero do frame final.<\/p>\n\n\n\n<p><strong>set_curr_frame(frame)<\/strong><br>Define o n\u00famero do frame que passar\u00e1 a ser o atual.<\/p>\n\n\n\n<p><strong>get_curr_frame()<\/strong><br>Retorna um&nbsp;<em>int<\/em>&nbsp;com o n\u00famero do frame atual.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Fun\u00e7\u00f5es Importadas de&nbsp;<strong><a href=\"http:\/\/www2.ic.uff.br\/pplay\/documentacao\/gameimage\/\" data-type=\"page\" data-id=\"107\">GameImage<\/a><\/strong><\/h2>\n\n\n\n<p><strong>collided(game_object)<\/strong><em>\/\/ Originalmente de <\/em><strong><a href=\"http:\/\/www2.ic.uff.br\/pplay\/documentacao\/gameobject\/\" data-type=\"page\" data-id=\"110\">GameObject<\/a><\/strong><br>Retorna um&nbsp;<em>boolean<\/em>&nbsp;que indica se esse objeto colidiu com o&nbsp;<em>game_object<\/em>.<\/p>\n\n\n\n<p><strong>collided_perfect(gameimage1, gameimage2):<\/strong><em>\/\/ Originalmente de <\/em><strong><a href=\"http:\/\/www2.ic.uff.br\/pplay\/documentacao\/collision\/\" data-type=\"page\" data-id=\"102\">Collision<\/a><\/strong><br>Retorna um&nbsp;<em>boolean<\/em>&nbsp;indicando se pontos n\u00e3o transparentes de dois&nbsp;<em>GameImages<\/em>&nbsp;colidiram.<\/p>\n\n\n\n<p class=\"obs\"><strong>Observa\u00e7\u00e3o:<\/strong>&nbsp;para entender melhor a diferen\u00e7a de&nbsp;<em>collided<\/em>&nbsp;e&nbsp;<em>collided_perfect<\/em>, visite a documenta\u00e7\u00e3o da classe&nbsp;<strong><a href=\"http:\/\/www2.ic.uff.br\/pplay\/documentacao\/collision\/\" data-type=\"page\" data-id=\"102\">Collision<\/a><\/strong>.<\/p>\n\n\n\n<p><strong>set_position(x, y)<\/strong><br>Define a posi\u00e7\u00e3o da&nbsp;<strong>Animation<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cria uma anima\u00e7\u00e3o composta por N frames (o&nbsp;frame inicial padr\u00e3o \u00e9 0).&nbsp;O m\u00e9todo&nbsp;set_sequence_time(ms)&nbsp;deve ser chamado antes de tentar rodar a&nbsp;Animation.&nbsp;O tamanho de cada frame \u00e9 calculado baseado no tamanho da imagem e no total de frames desejado. Exemplo: Fun\u00e7\u00f5es da Classe Animation(image_file, total_frames, loop=True)Cria uma anima\u00e7\u00e3o a partir do image_file, com total_frames. set_sequence(initial_frame, final_frame, loop=True)Define [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":38,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"document-template.php","meta":{"footnotes":""},"_links":{"self":[{"href":"http:\/\/www2.ic.uff.br\/pplay\/wp-json\/wp\/v2\/pages\/93"}],"collection":[{"href":"http:\/\/www2.ic.uff.br\/pplay\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www2.ic.uff.br\/pplay\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www2.ic.uff.br\/pplay\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www2.ic.uff.br\/pplay\/wp-json\/wp\/v2\/comments?post=93"}],"version-history":[{"count":10,"href":"http:\/\/www2.ic.uff.br\/pplay\/wp-json\/wp\/v2\/pages\/93\/revisions"}],"predecessor-version":[{"id":498,"href":"http:\/\/www2.ic.uff.br\/pplay\/wp-json\/wp\/v2\/pages\/93\/revisions\/498"}],"up":[{"embeddable":true,"href":"http:\/\/www2.ic.uff.br\/pplay\/wp-json\/wp\/v2\/pages\/38"}],"wp:attachment":[{"href":"http:\/\/www2.ic.uff.br\/pplay\/wp-json\/wp\/v2\/media?parent=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}