Pixi.js Tutorial For Complete Beginners - Create 2D Games & All Sorts Of Interactive Content With JS

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024

Комментарии • 139

  • @WaelYasmina
    @WaelYasmina  3 месяца назад

    Pixi.js v8
    Videos
    ruclips.net/p/PLjcjAqAnHd1ELH6j5RZaT2Ilvwj1sMCi6
    Article
    waelyasmina.net/articles/pixi-js-tutorial-for-complete-beginners/

  • @nikolajankovic3073
    @nikolajankovic3073 2 года назад +72

    Recently I applied for a job and they asked me to develop a game using Pixi JS. In that moment I didn't even know what Pixi JS is but I managed to develop that game because of this tutorial and got my first job as developer. Thank you!

    • @WaelYasmina
      @WaelYasmina  2 года назад +11

      Congratulations! I'm so glad to hear that!!

    • @dvz131
      @dvz131 2 года назад +6

      I wish I had seen the video when I had my test

    • @gorankukic777
      @gorankukic777 Год назад +1

      Nikola, kako se zove firma u kojoj si dobio posao? Sutra krećem da radim u novoj firmi sa Pixi-jem :)

    • @redisotschek8643
      @redisotschek8643 Год назад

      Hi there! So glad for you❤
      Any open positions?🫣

  • @slambingo_
    @slambingo_ 4 месяца назад +1

    2:10 If this doesn't work for somebody, try this:
    Start();
    async function Start()
    {
    const app = new PIXI.Application();
    await app.init({ width: 640, height: 360 });
    document.body.appendChild(app.canvas);
    }

  • @n1kb0t
    @n1kb0t Год назад

    Thanks, very interesting. Such a good explanation, even a beginner can understand.

  • @timofeybabisashvili7077
    @timofeybabisashvili7077 5 месяцев назад

    Awesome! Great video! Huge thanks

  • @FVVictor
    @FVVictor 2 года назад

    Thanks a lot! Greetings from Brazil :)

    • @WaelYasmina
      @WaelYasmina  2 года назад

      You're welcome!
      I ❤️ Brazil

  • @vishnubhaskaran2521
    @vishnubhaskaran2521 10 месяцев назад +1

    if anyone is stumpled upon the Pixi loader then try using the below code
    // Load the enqueued assets
    PIXI.Assets.load('../../assets/images/zombiefiles/png/male/Attack (5).png').then((texture) => {
    // Once assets are loaded, create a sprite from the texture
    const char4Sprite = new PIXI.Sprite(texture);
    // Position your sprite as needed
    char4Sprite.y = 450; // Set the y position as needed
    // Add the sprite to the stage
    application.stage.addChild(char4Sprite);
    }).catch((error) => {
    console.error('Error loading assets:', error);
    });
    Basically in the modern version pixi is providing Assets class for loading assets.

  • @custardcream2226
    @custardcream2226 2 года назад

    Awesome video, great pace, thanks! )

  • @shivamjha2625
    @shivamjha2625 2 года назад

    Great video, much thanks

  • @theman7050
    @theman7050 2 года назад

    Thank you.!!!!

  • @Schwartz866
    @Schwartz866 Год назад

    Why not use web server ?

  • @alexfrozen
    @alexfrozen Месяц назад

  • @sugendhamangla5868
    @sugendhamangla5868 Год назад +3

    i am getting an error below
    Uncaught TypeError: Cannot read properties of undefined (reading 'shared')
    at app.js:76:33
    127.0.0.1/:1 Refused to execute script from '127.0.0.1:5500/node_modules/@pixi/graphics-extras/lib/' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
    (index):50 Live reload enabled.
    :5500/favicon.ico:1 Failed to load resource: the server responded with a status of 404 (Not Found)

  • @alekseiperedurowain7730
    @alekseiperedurowain7730 Год назад +8

    Did anyone else get to 27:00 and gut stuck on the line `const loader = PIXI.Loader.shared` ? With errors suggesting that Loader is not defined? I'm big confuse : everything else
    worked fine for me in this tutorial up to that point.

    • @spixels6880
      @spixels6880 Год назад +3

      Same...

    • @h3avyl
      @h3avyl Год назад +1

      Same problem here : const loader = PIXI.Loader.shared gave me a very frustrating error...

    • @miki-g4q
      @miki-g4q Год назад +1

      sorry. I cannot use english well.
      but i think you must change pixi.js version.
      In PixiJS 7, PIXI.Loader.shared is deprecated.
      So, if you change the version to 6 as shown in this video, the error will disappear. I hope this helps you solve the issue.

  • @TurtleKun
    @TurtleKun 9 месяцев назад +1

    I was stuck on the loader part and got the error "reading shared", in PIXI v7 they removed the loader and added Assets and Sprite. Just a heads up for anyone else stuck!

    • @TurtleKun
      @TurtleKun 9 месяцев назад +1

      This is how i have my 'setup' function now:
      const loader = PIXI.Assets
      const Sprite = PIXI.Sprite
      async function setup (resource, spriteName){
      let texture = await loader.load(resource)
      spriteName = Sprite.from(texture)

      spriteName.y = 400
      app.stage.addChild(spriteName)
      }
      setup("path/to/sprite.jpg", "char4Sprite")

  • @nandoaires
    @nandoaires 3 года назад +2

    I hate you because you just made me want to play Phantasy Star 4 again while I'm working.
    (Just kidding, loved the tutorial and the references! :) )

    • @WaelYasmina
      @WaelYasmina  3 года назад +3

      Haha man I LOVE that game! I have finished it multiple times on MegaDrive back in the day and I still play it on online emulators from time to time.
      Thank you!

  • @snakemanluffy7645
    @snakemanluffy7645 3 года назад +8

    Thank you for such an amazing tutorial. I've watched the whole video while also coding but I didn't quite get some of the object's properties/methods around my head but I guess it's because it's my first time trying something like this. feels amazing. I have to explore & practice.

    • @WaelYasmina
      @WaelYasmina  3 года назад +4

      Thank you very much!
      Don't worry, just a bit of practice and you'll be fine. Everything has a learning curve.

  • @theoryofeverything2150
    @theoryofeverything2150 2 года назад +5

    This is the best pixijs tutorial that I’ve had. Thank you so much. Please do a Udemy pixijs lesson or any other pixijs video compilation and I’ll buy.

    • @WaelYasmina
      @WaelYasmina  2 года назад

      You just made my day with such kind comment, thank you very much! I really appreciate it!

  • @timotheeastier249
    @timotheeastier249 Год назад +6

    This was amazingly well made and clear. Thank you!

  • @ΙΩΑΝΝΗΣΤΖΙΑΚΑΣ
    @ΙΩΑΝΝΗΣΤΖΙΑΚΑΣ 3 года назад +3

    Now i can believe on humanity, some with real knowlegde give it to us with the most simple way.Very good explanation!

    • @WaelYasmina
      @WaelYasmina  3 года назад +1

      This comment made my day! I really appreciate your kind words, thank you very much!

  • @terric8501
    @terric8501 Год назад +1

    When I try to use PIXI.Loader.shared I just get this error message:
    "Uncaught TypeError: Cannot read properties of undefined (reading 'shared')"
    Do you have to install something separately?

  • @michaelmarocchi3503
    @michaelmarocchi3503 7 месяцев назад

    ok, i finished your video and i wanna tell you THANK YOU. The only "bad thing" i found, is that "loader" didn't work, so in the last minutes, i'm not strong enough to let the dragon "fly". Also the music gave me problem after i installed howler. It did not sound at all on me :( maybe my foult but nothing found in console about it :S

  • @mycloudvip
    @mycloudvip 7 месяцев назад

    Awesome content! How do you use this library for production? do you have a tutorial on that? Thanks!

  • @prantoislam5529
    @prantoislam5529 Год назад

    hi, im getting errors setting it up. Where can I show my problems or who can I seek for help?

  • @innocentcarrot5832
    @innocentcarrot5832 7 месяцев назад

    I followed the steps but at 1:59, I did not see the text on the console on my screen, what could be the problem.

  • @CodeSmart_
    @CodeSmart_ Год назад +1

    i'm so thankfull that i found your chanel!!! EXCELENT CONTENT ☺☺♥

  • @myomyintaung1516
    @myomyintaung1516 Год назад

    how to use new pixi.js version with vue 3 sir, any ideas for this?

  • @bonanzainteractive7771
    @bonanzainteractive7771 5 месяцев назад

    please create a video to demonstrate how to use spine in pixi

  • @II-is4ft
    @II-is4ft Год назад +1

    Thank you - it’s the best game dev introduction that I ever seen

  • @ruckboger
    @ruckboger 2 года назад +1

    Good stuff! I used the steps on the Webpack startup page so that I can use standard Node syntax and have a local environment with a dev server so I can use localhost:3000.

    • @WaelYasmina
      @WaelYasmina  2 года назад +1

      Thanks!
      Generally speaking, I highly recommend learning and using a bundler like Weback or Parcel even for people who are new to the world of web development. However, in this case where I assume you don't know how to use one so you had to go learn one then come back to learn Pixi. It would be easier if you just installed the LiveServer extension that I used in the tutorial so that you focus on one only thing.
      Anyways, you did what it seemed right for you and it worked fine so that's a win I guess.

  • @helguuhucu
    @helguuhucu 10 месяцев назад

    Hi! First of all, thank you for this tutorial. It really introduces the basics of Pixi JS and prepares us for doing more.
    However, I have come across a few problems. I wonder if it occured to others to and I am hoping I can find some solutions.
    1. The loader.shared class/function is not working for me, no matter what I try. It says cannot read properties of undefined (reading 'shared') pixijs
    2. The graphics extra pack was not working either, and I proceeded as in the video. The star and the other thing would not appear and no error was given either.

  • @SomeIrishLad
    @SomeIrishLad 7 месяцев назад

    This video is great. The documentation is a bit overwhelming when you are completely new to PixiJS.

  • @jugibur2117
    @jugibur2117 Год назад

    First thanks for your effort! PIXI seems more intuitive for me as Phaser.
    But a Question at 32:98 : I honestly don't understand that behavior. Yes, it points to the same texture object, but you have set a different rectangle. So I assumed it just copied this other part from the texture bitmap. Intuitively, it seems inefficient to me in this way to load a whole new instance of a texture of the *same* bitmap into memory.

  • @felipe_crea
    @felipe_crea 3 года назад +2

    Excelente tutorial, muchas gracias, tienes una gran "pedagogía"

    • @WaelYasmina
      @WaelYasmina  3 года назад

      Thank you! I really appreciate your positive feedback.

  • @dnbc177
    @dnbc177 Год назад

    It doesnt recognise npm what is that?

  • @nelsinosouza8387
    @nelsinosouza8387 2 года назад +1

    Thank you for the effort to build this tutorial, now I feel prepared to explore the official pixiJS documentation!

    • @WaelYasmina
      @WaelYasmina  2 года назад

      Nice!
      Thank you for your kind words.

  • @smyrnian_
    @smyrnian_ Год назад +1

    Awesome demo, thank you!

  • @naidenovt
    @naidenovt Год назад

    Awesome tutorial man! Can you help me with one task they gave me for the job interview ? Will be much appreciated!

  • @manaswini713
    @manaswini713 4 месяца назад

    nice tutorial thanks man

  • @botanicspark
    @botanicspark Год назад +1

    Great and clear tutorial. Thank you!

  • @amventures1
    @amventures1 Год назад

    Thank you.
    Looking forward for extended tutorial (or better project example) on PixiJS

  • @danielmarcano752
    @danielmarcano752 11 месяцев назад

    Amazing video! Quite a lot of knowledge, but you have made it very easy to follow along.

  • @sSJunSs
    @sSJunSs 3 года назад +1

    Thank you from Korea
    so wonderful tutorial

  • @iilyaa
    @iilyaa Год назад

    Where to find textures pack?

    • @WaelYasmina
      @WaelYasmina  Год назад

      github.com/WaelYasmina/pixitutorial/tree/main/images

  • @kirilkorukov1031
    @kirilkorukov1031 7 месяцев назад

    thank you brother for this tutorial, really good job

  • @SrrePro
    @SrrePro 6 месяцев назад

    Great job!!!

  • @vishnubhaskaran2521
    @vishnubhaskaran2521 10 месяцев назад

    Thanks for the tutorial mate, it is super helpful

  • @Nerdle
    @Nerdle 2 года назад

    Thank you for this tutorial! You've gained a new subscriber.

    • @WaelYasmina
      @WaelYasmina  2 года назад

      That's so kind of you! Thank you

  • @DagestanShop
    @DagestanShop 2 года назад

    35:20 when try
    function setup() {
    const texture = PIXI.Texture.from('blob_1.png')
    console.log(texture)
    const sprt = new Sprite(texture)
    sprt.position.set(50,50)
    console.log(sprt)
    app.stage.addChild(sprt)
    }
    get uncaught promise error , should i ihave also blo_1.png separate file ?

    • @WaelYasmina
      @WaelYasmina  2 года назад +1

      I don't get what you mean by having blo_1.png as a separate file.
      Can you copy and paste me the entire error message.

    • @wasuuu
      @wasuuu 2 года назад

      @@WaelYasmina There's unfortunately no error message. It just shows up as uncaught promise error :(

    • @WaelYasmina
      @WaelYasmina  2 года назад +2

      Are you running your project on a local server?

    • @DagestanShop
      @DagestanShop 2 года назад

      @@WaelYasmina yes , but I already switched to phaser )

    • @wasuuu
      @wasuuu 2 года назад

      @@WaelYasmina Yes, all the files are local

  • @asyncasync
    @asyncasync 2 года назад

    I am writing a physics simulator and am using native canvas right now. My fear is performance when I start to scale things up. It seems to be getting laggy with only 300 particles already.
    So my thought was to replace the canvas rendering with WebGL. Trouble is it looks tremendously complex to code. I don't want to worry about buffers and memory allocation, but I do require high performance.
    Does it make sense to then to replace canvas with PIXIJS instead? Would it increase the performance?
    If it would increase the performance then why doesn't canvas do whatever PIXIJS + WebGL does under the hood, as they both use the GPU? Is it that PIXI slightly more complex to code compared to native canvas so they kept it that way? If the difficulty is the same I don't see why canvas is not deprecated then. Compatibility?

    • @WaelYasmina
      @WaelYasmina  2 года назад

      I'm not an expert in the matter so I can't give you precise answers to these questions, unfortunately. However, here's something that might be a little insightful regarding your last question (read the last 2 paragraphs of the chosen answer):
      stackoverflow.com/questions/36908427/webgl-vs-canvas-2d-hardware-acceleration
      Now from what I understand from those paragraphs, the main difference between WebGL and 2D Canvas is that the latter lets the browser handle all the optimizations. while the former gives you the total control to do the optimizations by yourself. And based on that, *I think* Pixi.js takes the control WebGL provides and does the optimization work for you behind the scenes.
      Anyways, I'd suggest you give Pixi.js a try which is super easy. Just learn the basic stuff that will make you able to do the same things that you are capable of using native canvas. And then based on the results you decide if you're satisfied or you need more advanced tools like shaders, buffers, etc...
      Finally, you can get better answers from real experts if you ask your questions here:
      github.com/pixijs/pixijs/discussions/
      www.html5gamedevs.com/forum/15-pixijs/

    • @asyncasync
      @asyncasync 2 года назад

      @@WaelYasmina thanks. If its easy to work with I guess I will just go ahead and try. Then I will do some stress testing, then checkout to the canvas implementation again and compare the results. If the bottleneck truly is the graphics drawing and not the physics calculations then I might see some improvement.

  • @பாமரமனசாட்சி

    Total summary in 1 line :
    "PiXi js " is a library like 'Photoshop '

  • @theman7050
    @theman7050 2 года назад

    At around 40:20, why didnt the newly added background got added on top of the previously added sprite, i.e. dragon? I mean the layer / stacking which you explaind earlier in the video is not applying here? :)

    • @WaelYasmina
      @WaelYasmina  2 года назад +1

      Smart question. My guess is that since the tiling sprites are mainly used for backgrounds, the creators of the library made it in a way that the tiling sprites have lower order compared to the other types of sprites thus they're placed behind. I'm not 100% sure though.

    • @theman7050
      @theman7050 2 года назад

      @@WaelYasmina makes sense. Thanks again.
      Love ur work

  • @goswamianshuman
    @goswamianshuman 2 года назад

    its very amazing that you are teaching this perfectly this component of js , very appreiciating !!!

  • @wasuuu
    @wasuuu 2 года назад

    Thanks for the quick reply, Wael. I've checked and the file path I've used is correct (I store app.js in the root directory and have a file called wine.png in the images directory, in root). For the file path used for importing the texture, I'm using `./images/wine.png`. The error message is as following:
    ===========================
    Uncaught (in promise)
    error { target: img, isTrusted: true, srcElement: img, eventPhase: 0, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, timeStamp: 99, … }

    bubbles: false

    cancelBubble: false

    cancelable: false

    composed: false

    currentTarget: null

    defaultPrevented: false

    eventPhase: 0

    explicitOriginalTarget:

    isTrusted: true

    originalTarget:

    returnValue: true

    srcElement:

    target:

    timeStamp: 99

    type: "error"

    : function isTrusted()

    : EventPrototype { composedPath: composedPath(), stopPropagation: stopPropagation(), stopImmediatePropagation: stopImmediatePropagation(), … }
    ===========================
    I'm not sure if this error has anything to do with crossorigin because it's not supposed to throw an error for CORs since I'm using a local file, but perhaps I'm wrong about this.
    Once again, thanks for your help!

    • @WaelYasmina
      @WaelYasmina  2 года назад

      Try using another browser. In the meantime, I'll create a small project and I'll send it to you so you can test and see if the problem comes from your code or from something else.

    • @WaelYasmina
      @WaelYasmina  2 года назад

      Well, I ended up uploading the entire project.
      github.com/WaelYasmina/pixitutorial

    • @wasuuu
      @wasuuu 2 года назад

      @@WaelYasmina Woah, thanks! Unfortunately the same issue still occurs :( I've added an issue to the repository so you could view it in more detail

  • @quinnstevens7970
    @quinnstevens7970 2 года назад

    Hi, when i try app.renderer it doesn't seem to work. The background colour doesn't change and the resize only stretches the height far down the screen. Do you know what might be wrong?

    • @quinnstevens7970
      @quinnstevens7970 2 года назад

      Okay I found a solution. Turns out it wasn't the renderer but for the background color. The issue was i spelt "colour" the UK way which simply doesn't work. I'm not sure as to why the resize wasn't working but I found that placing "resizeTo: window" inside the configuration object works the same

    • @WaelYasmina
      @WaelYasmina  2 года назад +1

      The resize method is there just in case you wanna resize the canvas later in your code. So yes, you can skip it and just set the size in the configuration object.

  • @iliqnew
    @iliqnew Год назад

    Yes. Great job! Thanks!

  • @namaefumei
    @namaefumei Год назад

    this really helped a lot! please do more!

  • @gebbygebbers
    @gebbygebbers 3 года назад

    Your teaching style is so great, it reminds me of my old vocational high school days! Thank you so much ❤

    • @WaelYasmina
      @WaelYasmina  3 года назад

      Thank you, glad you think so!

  • @Leonardo-qe1on
    @Leonardo-qe1on 3 года назад

    is it possible to create a multiplayer? what would you use?

    • @WaelYasmina
      @WaelYasmina  3 года назад

      Of course it is.
      I'd use Node.js, Express and Socket.io

  •  3 года назад

    I think it would be my new favorite channel

    • @WaelYasmina
      @WaelYasmina  3 года назад

      That's nice to hear! thank you!

  • @monsieurbouclier7341
    @monsieurbouclier7341 2 года назад

    Very good tutorial, thank you for all your work on it.

    • @WaelYasmina
      @WaelYasmina  2 года назад

      I appreciate your kind words. Thank you!

  • @sambhavsaraswat5585
    @sambhavsaraswat5585 2 года назад

    The docs gave me a nightmare this tutorial is great

  • @prnvrna
    @prnvrna Год назад

    Thank you!

  • @thesuperyou2829
    @thesuperyou2829 2 года назад

    Hats off man!!!!!!!!!!!!!!!!!!!!!

  • @sntlol
    @sntlol 2 года назад

    did you have a video for pixi spine?

    • @WaelYasmina
      @WaelYasmina  2 года назад

      No, but it's in my to-do list.

  • @emmanuellazarte8904
    @emmanuellazarte8904 3 года назад

    Thx.! you're the best one :D

  • @PawelGrzelak
    @PawelGrzelak 2 года назад

    Great tut quality.

  • @joaocesarlima7339
    @joaocesarlima7339 3 года назад

    Excellent tutorial! Thanks a lot!

  • @vikingvikingviking2806
    @vikingvikingviking2806 3 года назад

    Great crash course! Thanks

  • @hakuenstudio
    @hakuenstudio 2 года назад

    Amazing tutorial!!

  • @sk3ptik0s49
    @sk3ptik0s49 3 года назад

    So far so good, this is my third tutorial lol

    • @WaelYasmina
      @WaelYasmina  3 года назад +1

      I'm also still researching and learning about this library, and I think it's worth every second I spend on it.
      I highly suggest you to bookmark the examples page! The examples are not hard to analyze and understand, and they can help you to better visualize the role of a lot of functions.
      pixijs.io/examples/#/demos-basic/container.js
      Good luck!

    • @sk3ptik0s49
      @sk3ptik0s49 3 года назад

      @@WaelYasmina Thank you very much for the heads up, that´s exactly how I learn the fastest with programming, copying examples and then trying to modify them. One thing that I miss, since I started last year studying with Java, is that when hovering above a method etc, an explanation is given, or better yet, you have the scroll down pop up with options. Can this be achieved with libraries such as this? I´m using VScode.

    • @WaelYasmina
      @WaelYasmina  3 года назад +1

      There are extensions you can add to VSCode which provide that feature. But it's rare to find one for libraries/frameworks (except popular ones like React or Angular).

    • @sk3ptik0s49
      @sk3ptik0s49 3 года назад

      @@WaelYasmina Well, I got a clickable rectangle moving already! These examples sure help a lot, along with the searchable documentation.

  • @ed1849x
    @ed1849x 2 года назад

    gracias

  • @swarupkesarkar2783
    @swarupkesarkar2783 3 года назад

    Most underrated channel ever. Best tutorial available for the language. Thanks!

    • @WaelYasmina
      @WaelYasmina  3 года назад

      I appreciate your kind words, thank you!

  • @elvinasss2767
    @elvinasss2767 3 года назад +3

    I'm already halfway this video and I can tell that is a HIGH quality tutorial that I wouldn't mind to pay for!. Thank you :)

    • @WaelYasmina
      @WaelYasmina  3 года назад +1

      That's so kind of you, thank you very much!

  • @javideas
    @javideas Год назад +1

    01:24 worked for me without console errors