How to load textures from a spritesheet in Godot 3 - godot

I've just got started with Godot yesterday, and I'm starting a game. I drew a few spritesheets for it. It seems much more efficient to pack all of the frames of an animation into a single image file, right?
Anyway, in Godot I have an AnimatedSprite, who of course has a SpriteFrames property, or whatever it's called. I want to split my spritesheet up into multiple images so that I can use each image as a separate frame in the animation, but as far as I can see Godot provides no such feature. Is this the case?
I've been searching for an answer on the web for a while now, and I can't find anything relevant.
I'd be very surprised if I can't do this in Godot, since I can do it in just about every other game engine I've seen.
Thanks!
(Just to clarify, I want to (programmatically or otherwise,) split a spritesheet into multiple textures, within Godot.)

Click New SpriteFrames in the Frames property menu of the AnimatedSprite node. Now click on the just created SpriteFrames next to the name of the Frames property. Animation Frames window should appear.
Click this Add frames from a Sprite Sheet button. Select your spite sheet file, set grid sizes and finally select individual frames from that sprite sheet.
(This works for me in Godot v3.2.2)

As it says: "Sprite node that can use multiple textures for animation."
Source: http://docs.godotengine.org/en/3.0/classes/class_animatedsprite.html
What you are searching for is using normal Sprite(2D), and set regions for it if you are using AnimationPlayer at each frame.
Example: https://www.youtube.com/watch?v=IGHcscKpA7Y
If you want to do all programmically, you just have to set the sprite to Sprite(2D), and then:
func _ready():
set_region(true)
set_region_rect(Rect2(positionx,positiony,width,height))
but i guess using AnimationPlayer is better option.
This is not tested because i should be sleeping right now, but it should work.

Related

How to animate resize/reposition of a Flutter Column when a child is added with a ScaleTransition

I'm implementing a login screen. It has a centred Column containing a TextField for entering an email address and a number of buttons for social sign-in. When a button is pressed, the Column is rebuilt with a CircularProgressIndicator (spinner) added at the bottom. I've wrapped the spinner in a custom widget that manages a ScaleTransition animation. That works OK, but the Column grows and shifts up to accommodate the final full size of the spinner immediately instead of moving smoothly with the animation.
I also wrapped the Column in an AnimatedSize widget using the same curve and duration as the ScaleTransition, but it hasn't helped. The root of the tree is a Consumer of the state that triggers the addition of the spinner so the animations should both be starting together. Maybe the the spinner needs to be permanent for this to work, but it doesn't seem desirable because its API doesn't provide a way to pause the animation. It would presumably constantly use some power to animate itself even when it isn't visible. I'm fussy about that sort of thing.
It looks like I might have to use an AnimatedList, but it doesn't seem semantically correct because the contents aren't really a list. So is there a more generic way to animate the size (and position) of parent widgets like Column and Center to track an animated size change of their children?

MergEXT MergZXing layer and barcode not reading

Just started working with this awesome external but have a couple of questions.
When the control is evoked, is it always the top layer or can I have a background transparent image on top of it so I can frame the control nicely?
Also, my testing seems to read most Barcodes but when it comes down to reading Barcodes on hard drives, the control does not want to decode those.... Too dense of bar code pattern?
I am very impressed thus far with the ease of use of your externals. Makes we want to code more for mobile devices!
an overlaying transparent image is not possible, as far as i know.
but couldnĀ“t you use
command mergZXingControlSetRect pLeft,pTop,pRight,pBottom
to define the rect of that scanner after creation
or
command mergZXingControlCreate pLeft,pTop,pRight,pBottom
to create the scanner control in the specified rect.
Set the rect smaller than the width and the height of the screen.
You could then use an underlying image, which is displayed outside of the scanner rect, to show the frame around scanner control. Did not test it myself, but i would assume that this should work.
Unfortunately the native controls in externals and the ones the engine provides are added as views on top of the LiveCode view. That means you can't intermingle LiveCode controls with them. One thing that some users have done is add a web view with a transparent background and a load a png image. If you create the barcode view first and the web view second then the web view will be on top.

How do I make a circle move on events?

I'm pretty new to javafx so I'm trying to learn here so please be reasonable and don't dis away my question, I really appreciate any help at all, thanks!
I would like to know how I could move an object, let's say this circle on different events, like keypress or mouseclick, mousemove, whatever.
Circle circle = new Circle();
circle.setCenterX(100.0f);
circle.setCenterY(100.0f);
circle.setRadius(50.0f);
Do I need to use that KeyFrame thing I saw on the javafx site tutorial, or how does this work?
I would not have asked this here if I weren't feeling so lost, honestly.
So to make this clear: What is the code for moving objects that I created, by using events?
EDIT: By moving it I mean, press up key and it moves up by a few pixels, transform it maybe, with another key, or click somewhere on the scene and make it move there instantly or travel there with a certain speed. I don't have to redraw it like you need to with html5 canvas, I hope, right?
I don't have to redraw it like you need to with html5 canvas, I hope, right?
Not if you are using a standard JavaFX scene graph as opposed to a JavaFX canvas.
I would like to know how I could move an object, let's say this circle on different events, like keypress or mouseclick, mousemove, whatever
There are three ways to move a Shape:
You can adjust the shape's geometry (e.g. the centerX/centerY properties of a circle).
You can adjust the shape's layout (e.g. it's layoutX/layoutY properties).
You can adjust the shape's translation (e.g. it's translateX/translateY properties).
You can think of the layout as the home position for the object; i.e. where it should normally be in the context of it's parent group. You can think of it's translation transform as a temporary position for an object (often used when the object is being animated).
If you are using a layout pane such as a VBox or TilePane, then the layout pane will handle setting the layout co-ordinates of the child node for you. If you are using a simple Group or a plain Pane or Region, then you are responsible for setting the correct layout values for the child nodes.
To listen for events, set event handlers on Nodes or Scenes.
Here is a small sample app which demonstrates the above. It places the object to be moved inside a Group and modifies the position of the object within a Group in response to various events.

How to stretch and scale a single child in a container(e.g. panel, groupbox) to fit different resolution screen? C#.net

Basically, I have an usercontrol as main container, inside which I have a few groupboxes and buttons. But, my interface controls will not be resized and positioned properly as what I expect in design interface.
I've already tried to change the anchor and dock properties but none of them serve my purpose.
I searched online and found something called viewbox in WPF, I'm wondering if there is something like "viewbox" in visual studio 2010?
Please help!
Try using TableLayoutPanel container and put your controls in it. It is similar to the idea of table in HTML where it is divided to rows and columns each one of them can be set to either a set of pixels or a percentage. Usually if you want to use re-sizable form, usually you should have a control that will give you good results when stretching such as image, multiline textbox etc... In addition, put the dock property to fill to get the stretching you want.
I hope this info was useful for you.

Silverlight 3 - Elements inside an element dont arrange sometimes

I have a grid/canvas that has an element (say an icon with an image and text overlayed) added to it dynamically via code.
Most of the time it renders correctly when added (content is aligned properly inside it),
but sometimes all the content sits in one corner.
I can remove/add/remove/add/remove/add and it will eventually do it
After a movement of the parent canvas, the element corrects itself as if the layout has been updated.
I have tried the following on Loaded and OnApplyTemplate for both the element and the element parent but it still seems to happen occasionally
InvalidateMeasure()
InvalidateArrange()
UpdateLayout()
Any ideas on why the content wouldn't arrange would be appreciated cause its driving me nuts
I'm not sure why it works for you sometimes but not others. But a grid has the inherent ability to dynamically resize itself and its contents. A canvas doesn't (you'd have to handle that manually in code).
If you change your canvas to a grid does it work? A grid has slightly more overhead than a canvas but it sounds to me like you need its functionality anyway.

Resources