Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

JOGO PLATAFORMA SIMPLES COM INIMIGO

Community Beginner ,
Jul 23, 2019 Jul 23, 2019

// COMO FAÇO PARA O FOGO CAIR DA PLATAFORMA TILES?

import flash.display.MovieClip; // Importar algumas bibliotecas

import flash.events.Event;

import flash.events.KeyboardEvent;

const gravity:int = 1;

const max_speed:int = 8;

const walkspeed:int = 4;

const jumpspeed:int = 25;

const start_x:int = 50;

const start_y:int = 50;

var y_speed:int;

var x_speed:int;

var left:Boolean;

var up:Boolean;

var right:Boolean;

var space:Boolean;

var can_jump:Boolean;

var level:Array = new Array();

var tiles:Array = new Array();

var Map_data = new Data; // Cria uma versão do Data.as

var Hero:hero = new hero;

var Fire:fire = new fire; // Adiciona fogo

BuildMap();

create_hero();

addEventListener(Event.ENTER_FRAME, main);

stage.addEventListener(KeyboardEvent.KEY_DOWN, key_down);

stage.addEventListener(KeyboardEvent.KEY_UP, key_up);

function main(event:Event){

Atualizar_heroi();

Atualizar_Fire();

}

function key_down(event:KeyboardEvent){

if(event.keyCode == 37){

left = true;

}

if(event.keyCode == 38){

up = true;

}

if(event.keyCode == 39){

right = true;

}

}

function key_up(event:KeyboardEvent){

if(event.keyCode == 37){

left = false;

}

if(event.keyCode == 38){

up = false;

}

if(event.keyCode == 39){

right = false;

}

}

function create_hero(){

addChild(Hero);

Hero.x = start_x;

Hero.y = start_y;

  ///////////////

addChild(Fire);

Fire.x =  1074;

Fire.y = 95;

///////////////

}

function Atualizar_heroi(){  // Coloque na tela

y_speed += gravity;

if(left){

x_speed -= walkspeed;

}

if(right){

x_speed += walkspeed;

}

if(up && can_jump){

y_speed -= jumpspeed;

can_jump = false;

}

if(y_speed > max_speed){

y_speed = max_speed;

}

Hero.y += y_speed;

Hero.x += x_speed;

    // MANTEM O PERSONAGEM NO CHÃO

for(var t:int; t < tiles.length; t++){

while(tiles.hitTestPoint(Hero.x,Hero.y + 10,true)){ // WHILE = ENQUANTO

Hero.y -= 1;

if(y_speed >= 0){ // Minha tentativa de não deixá-lo saltar de estado sem mudar o mais quente

can_jump = true;

}

}

while(tiles.hitTestPoint(Hero.x,Hero.y - 10,true)){

Hero.y += 1;

y_speed = 0;

}

while(tiles.hitTestPoint(Hero.x + 5,Hero.y,true)){

Hero.x -= 1;

}

while(tiles.hitTestPoint(Hero.x - 5,Hero.y,true)){

Hero.x += 1;

}

}

x_speed = 0;

}

function Atualizar_Fire(){  // Coloque na tela

Fire.x -= 2;// Fogo

trace(Fire.x)

    // MANTEM O PERSONAGEM NO CHÃO

for(var t:int; t < tiles.length; t++){

while(tiles.hitTestPoint(Fire.x -2,Fire.y, true)){ // WHILE = ENQUANTO

/*while(tiles.hitTestPoint(Hero.x - 5,Hero.y,true)){

Hero.x += 1;

}*/

Fire.y -= 2;

}

}

//Hero.y -= 2;

x_speed = 0;

}

function BuildMap(){

Map_data.Setup(); // Dados de configuração do arquivo externo

level = Map_data.level1; // Obtém dados do arquivo externo

for(var t = 0; t < level.length; t++){

for(var u = 0; u < level.length; u++){

if(level != 0){ // Se os dados não forem nulos

var new_tile:platform_tile = new platform_tile; // Do que construir um bloco

addChild(new_tile); // Coloque na tela

new_tile.gotoAndStop(1);

new_tile.x = u * 60;

new_tile.y = t * 20;

tiles.push(new_tile); // Colocá-lo em uma matriz

}

}

}

}

TOPICS
ActionScript
371
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2019 Jul 23, 2019

Olá.

Será difícil analisar o que você quer sem que possamos ver o FLA e os outros arquivos. Você pode compartilhá-los aqui?

E também precisamos de mais detalhes sobre o que exatamente você não está conseguindo fazer. Porque essa informação de "o fogo cair da plataforma tiles" está bem vaga e confusa.

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 24, 2019 Jul 24, 2019

Aqui está. Como eu faço para mover o fogo via código e fazer a carne

aparecer via código também!

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 24, 2019 Jul 24, 2019

Olá.

Não apareceu nenhum link.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 24, 2019 Jul 24, 2019
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 24, 2019 Jul 24, 2019
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 24, 2019 Jul 24, 2019

FOI ERRADO FALTO UM ARQUIVO; AGORA TA TUDO CERTO BLZ VALEU PELA AJUDA...https://mega.nz/#!SzoUVAiA!l1sPuGyBKfkWYN_5bmZea7TMPqgsyx6N6eD4eRplxKc

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 24, 2019 Jul 24, 2019

Muito obrigado pelos arquivos.

1 - Para mover o fogo, você precisa de variáveis de velocidade somente para o fogo. Do jeito que está agora, você está usando as mesmas variáveis de velocidade para o jogador e para o fogo. Então sua função de mover o fogo ficaria assim:

const firespeed: int = 1;

function Atualizar_Fire()

{

    x_speed_fire += firespeed;

    y_speed_fire += gravity;

  

    if (x_speed_fire > max_speed)

        x_speed_fire = max_speed;

    if (y_speed_fire > max_speed)

        y_speed_fire = max_speed;

  

    Fire.x += x_speed_fire;

    Fire.y += y_speed_fire;

    for (var t: int; t < tiles.length; t++)

    {

        while (tiles.hitTestPoint(Fire.x, Fire.y + 10, true))

            Fire.y -= 1;

    }

}

Note que eu criei uma constante para a velocidade do fogo também.

2 - Em relação à carne, você pode simplesmente criar um MovieClip na Biblioteca chamado Meat, exportá-lo para ActionScript e então adicioná-lo, logo após a chamada da função BuildMap assim:

var meat:Meat = new Meat();

meat.x = 2 * 60;

meat.y = 4 * 20;

addChild(meat);

Espero que ajude.

Não hesite em perguntar se você tiver mais dúvidas.

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 25, 2019 Jul 25, 2019

Obrigado tirou todas minhas dúvidas! Antes eu estava fazendo por movie clip mais fica meio estranho e agora ta show!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 25, 2019 Jul 25, 2019

Porque não consigo fazer um random de x e de y?

var fire_newx:Array=new Array(-27,-27,-27,1069,1069,1069);

var fire_newy:Array=new Array(97,298,498,97,298,498);

quando o fogo fazer o hit com as paredes laterais como faço?

Queria fazer ele random de todos os lados e não deu certo...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 26, 2019 Jul 26, 2019
LATEST

JA DESCOBRI VALEU ERA SO FAZER UM IF LA DENTRO COM X < OU > VALEU...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines