• Content Count

  • Joined

  • Last visited

About cpu_sam

  • Rank
    Advanced Member

Contact Methods

  • Twitter
  1. The games MUST be made with Unity or C2?
  2. [NOTE: sorry for the post resurrection, but we can learn a bit more with it) Maybe you already solved that, but I will make some observations: You MUST study about state machines, basically I'm talking about automaton finite deterministic (AFD) For example, with a AFD, you can control each state of the entity and change when the player or AI changes: //NOTE: this object.state goes in object as a member, assign its value to IDLE (first state) function update ( ) { switch (object.state) { case IDLE: { //the idle code stay here } break; case WALK: { //the walk code stay here } break; case JUMP: { //the jump code stay here } brek; default: object.state = IDLE; break; } } And so, you must change the object state through the variable member object.state Think like if each state was independently of each other. So, the IDLE has the own code, WALK has another and JUMP has other. Each state process the input with diferents ways, see like a code can be: //NOTE: this object.state goes in object as a member, assign its value to IDLE (first state) function update ( ) { switch (object.state) { case IDLE: { //the idle code stay here //process inputs in IDLE state if (keyPressed == RIGHT || keyPressed == LEFT) { object.state = WALK; break; } //this function check if the object is touching the ground if (!object.isGround())//if no { object.state = FALL; break; } } break; case WALK: { if (!object.isGround()) { object.state = FALL; break; } //the walk code stay here //process input in WALK state if (keyPressed == RIGHT) moveToRight(); else if (keyPressed == LEFT) moveToLeft(); //should be stop else { object.state = IDLE; break; } } break; case JUMP: case FALL: { //the jump/fall code stay here if (keyPressed == RIGHT) moveToRightOnAir(); else if (keyPressed == LEFT) moveToLeftOnAir(); //if touchs grounds is idle if (object.isGround()) { object.state = IDLE; break; } } brek; default: object.state = IDLE; break; } } In the code above, we can see that each state holds diferents codes, it's more modular, and any state can survive without any other state. What can I say with all things? Simple, with state machines your code will stay more readable and easy to expand to more complex code without lost of sense. Imagine a code with 8K lines, if you follow making the code like you were making, you will finish in problems. If you use the state machine way, your code will stay more easy to mainutence. Now the jump problem. In the code that I show to you, you can verify if the player is jumping over the enemy or just falling above it. Just check the object.state value and you'll see what the player is acting. So in this way, you just need add more code on the JUMP/FALL state part and check if the enemy is down on the player feet. If so, you can die the enemy calling a method inside the own enemy (something like enemy.kill()) to send the message to enemy do the kill()
  3. cpu_sam

    Please, write your advices how to learn English

    I like to write, but only on my language: portuguese (pt BR). But, I can write not so well in English, that kind of tip I like very much and I will follow it to learn better how to write in English. NIOTE: even if I can write some phrases I can't express mysefl so well. I made a course, but not learn so well because I was very lazy. What gave to learn I learn it, but I feel that it can be more effective. Thanks for the tips.
  4. cpu_sam

    Phaser not show sprite images in chrome 65 Linux

    Don't worry man, I found a similar issue, but without any solution yet (just chrome linux stay in this way): https://github.com/photonstorm/phaser/issues/1962 I'm using the parcel as server of the files, even using apache2 I can't see any sprite. I will try in windows and see what I can do. So, Thank you for the help.
  5. cpu_sam

    Phaser not show sprite images in chrome 65 Linux

    I've tried run the game in firefox quatum and works fine. In chrome it loads the resource but in the moment of show the sprites are like invisible, without any resource is seen. The buttons are invisible but clickable because putting the cursor over the black position where it was, the cursor change the icon to pointing hand. It's impossible to load the game in chrome without a previous build in parcel, it give: Build with parcel in chome but serving by the apache2, give the same first error (without visible sprites. Opening in chrome 66 (android), the game opens and run withiout any error. Just chrome 65 linux give the first error.
  6. Hi, I'm trying to show some sprites of my game, but I get all invisible sprites. In firefox 60, the game works perfectly, only in chrome that the screen stays black and without any sprite visible. NOTE: No error message are reported, only this following: I'm using parcelJS as bundler. What should I do to fix this? EDIT: I'm using Phaser 2.10.5 with Typescript
  7. cpu_sam

    How to load file fonts from format fnt?

    Thank you @casey, but yesterday I made my own converter from fnt (from Hiero) to xml. It jwas just needed to add xml's tags and attributes.
  8. I'm trying to load a simple font, but phaser only reads xml. Can anyone teaches me how to convert a file fnt to xml? Because I can't load in phaser-ce, just give me the follow error: Phaser.Loader - jumpman: invalid XML Phaser.Loader - bitmapfont[jumpman]: invalid XML Line of code error: game.load.bitmapFont("jumpman", "./assets/fonts/fonteArial.png", "./assets/fonts/fonteArial.fnt"); Please someone give me a light!
  9. So, how do this? I want that because I try to load non existent asset but nothing is happening, the programs stop without any error message.
  10. cpu_sam

    eLearning game for kids that teaches Javascript and Python

    Just give a hint: if you can so put some images in the post, because the image motivates to visitates the site more than any text.
  11. Thanks, I'll follow this issue.
  12. I was thinking that Sprite.update was called every frame update automatically. Like I've searched for some human example and not found any, so I cannot to learn the "right"way. And once time again @samme thanks a lot!
  13. cpu_sam

    Help with simple code with ES6 and phaser 3

    I abandoned ES 6 and now I use pure Typescript 2, thanks for the attention.
  14. Reading this topic above, I've found that Sprite.update it's not called, however: how can I call the update in the main.update? I've tried the code in the topic but it doesn't works for me, that without the directly reference to player object. But I would like to call the Player.Sprite.update without the player reference explicitly declared in the source. Can anyone help me?
  15. cpu_sam

    About Javascript and Typescript with Phaser

    Ok, thank you for the answers. I was planning toi change JS for the TS. Now I can finally make one simple example with TS after many hours trying.