![]() in your case I would give the owner a punchBox:FlxObject (that is positioned relative to the owner when it moves), check the animation frame to determine whether the punchBox is solid and then have the FlxState check overlaps between the punchBox and the punchable group whenever punchBox.solid = true Thoughts?typically my collision happens in the FlxState's update method, I would make it so the FlxState can tell whether conditions were right to do a collision check and perform the FlxG.overlap check. I'm using FSM with a punch state, and I was thinking about checking if the animation is on a frame, then do the collision check. Is there a best practice for checking collision detection with another object during the animation. i've removed the bottom of this post where I say otherwiseĪt 4/8/20 02:03 PM, GeoKureli wrote: At 4/7/20 09:10 PM, catproX wrote: I just use uniformly spaced spritesheets, because I think it's beneficial to the player to have blocky sprites with matching hitboxesĮdit: didn't realize Flixel could use non-uniform spritesheet's. ![]() You can have as many hitboxes per sprite as you feel often I'll set my player's sprite's hitbox for level collision but give it's class FlxObject properties like attackBox and hurtBox and use them via:įlxG.overlap(player.attack, attackableGroup, onPunchEnemy) Return distanceSqruared < cRad*cRad + kRad*kRad Īditionally you use multiple hitboxes per object. Var distanceSqruared = distance.lengthSqaured Var distance = FlxVector.get(circle.x, circle.y).subtract(killer.x, killer.y) You can specify a notify callback and process callback to FlxG.overlap to perform advanced checks, like if you want something to be a circle, you can doįlxG.overlap(m圜ircle, circleKillerGroup,įunction circleNotif圜allback(circle:FlxSprite, killer:FlxSprite):Voidįunction circleProcessCallback(circle:FlxSprite, killer:FlxSprite):Bool ![]() Yes, you may need to fit your graphic to a more sqaure-ish shape, but there are other options. For example, if you loaded in a 32x32 graphic but want a 16x16 hitbox aligned to the bottom-center of the graphic you would do: sprite.width = 16 Īnd while flixel is very heavily geared towards square hitboxes (in fact, it doesn't have other shapes available out-of-box), this is surprisingly less limiting than one would think for most action games. you can override this by editing the width, height and offset properties. When a FlxSprite's graphic/animation is changed it automatically sets the hitbox to that graphics frame size. I'm also fairly new to TexturePacker, I might be missing something in the spritesheet/atlas publish settings. Extra graphical bits, like the gun, wouldn't count regarding collision. In Godot, I would set a collision shape (such as a capsule) and align it center of the sprite. If this is not the case, I may have to rethink and simplify my character composition and keep it in a more defined "squared" space.įor example, I've been playing around with this gun-toting-plague-doctor character that I've created for the game jam.īut the collision doesn't seem to line up properly with the hand drawn frames within the sprite. I did see a method for updating the hitbox if you scale the sprite, but that seems different than having a hitbox smaller than the view-able graphical area. Is there a way to set the size of the collision box? It seems like much of the characters graphical space and the hit box are one in the same. My apologies for asking a lot of questions, but I'm new to haxeflixel.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |