PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 30, 2022

[FIXED] How to Crop a image using gdscript in Godot?

 July 30, 2022     gdscript, godot, image, slice     No comments   

Issue

I am making a game in Godot and took a 2d Sprite sheet with lots of pictures in it and I wanted those pictures to be cropped accordingly and store them in an array so I can use them later, But the problem is that Godot has no function that crops the image acc to given Rect2 prams,

so, please Help out.


Solution

If you are working with sprites and you have a sprite sheet. You can configure the Hframes and Vframes of your Sprite node to match the rows and columns of your sprite sheet. Then specify what sprite you want using the frame property.

Alternatively, you can use a CanvasItem node (any Control or Node2D, including Sprite) and use draw_texture_rect to draw only a portion of a texture on it.

Other options include a custom shader, and using C# to manipulate images. However, assuming you want sprites, the above should suffice.



Answered By - Theraot
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing