Closed shinriyo closed 6 months ago
Hi @shinriyo ! You can use de Mixin Attackable in your game decoration. Wen die (this method is called when your life is equal 0). You can remove this component
Thank you. I will try. Don't close the ticket until doing it.
I wanted to set only 1 life
@override
void initialLife(double life) {
super.initialLife(1);
}
but it wasn't make sense.
finally, I did like the below. Is it in accordance with your design intent?
class ColumnDecoration extends GameDecoration with Attackable {
ColumnDecoration(Vector2 position)
: super.withSprite(
sprite: CommonSpriteSheet.venderMachine,
position: position,
size: Vector2(DungeonMap.tileSize, DungeonMap.tileSize),
) {
// I added here
initialLife(1);
}
Yeah, is it. Set the initial life in the constructor.
@RafaelBarbosatec
isVisible
has no effect.
It momentarily is invisible, but it becomes visible again.
@override
void die() {
super.die();
isVisible = false;
}
Hi @shinriyo ! Yes, there is a routine that update this variable. Why can you set isVisible = false?
because, I want to hide the object
You can create you won variable to control call or not the super.render . Or only change the opacity. The variable isVisible is used to control if that component position is visible in camera
You can do it
bool myIsVisible = true;
@override
bool get isVisible => myIsVisible ? super.isVisible : false;
I tried but I couldn't resolve.
What I want to do is to disappear a few minit and revive like the block of the game. https://www.youtube.com/live/J9xl0Jt6ohw?si=v-7AppwX_3WOsg_H&t=397
bool myIsVisible = true;
@override
bool get isVisible => myIsVisible ? super.isVisible : false;
@override
void initialLife(double life) {
super.initialLife(1);
}
@override
void die() {
super.die();
myIsVisible = false;
stopFiveSeconds();
}
Future<void> stopFiveSeconds() async {
while (true) {
await Future.delayed(const Duration(seconds: 5));
revive();
myIsVisible = true;
}
}
Got it.on second thought what you did do make sense. I will rename the isVisible to isVisibleInCamera and create a bool variable named 'visible' to control if render or not the component. Remembering that setting visible=false is not disable the block movement collision.
I didn't need while (true)
.
How to disable collision?
In the next Bonfire version (it will release maybe tomorrow ). isVisible = false will works.
To disable BlockMovementCollision just do override in onBlockMovement
and return false.
So, if you want disable collision when isVisible == false, just do it:
@override
bool onBlockMovement(
Set<Vector2> intersectionPoints,
GameComponent other,
) {
return isVisible;
}
In the next Bonfire version (it will release maybe tomorrow ). isVisible = false will works.
Thank you! I am waiting.
To disable BlockMovementCollision just do override in onBlockMovement and return false.
I added with BlockMovementCollision
for ColumnDecoration
class.
It has many override methods. but I also added Movement
class. I resolved it.
But, when myIsVisible = true
and it appears again, It appears strange in position.
Version 3.0.7 available
3.0.7
is newer than develop branch?
Is the same code
I changed. But, I didn't attach Pushable
to ColumnDecoration
class, but I can push it.
class ColumnDecoration extends GameDecoration
with Movement, BlockMovementCollision, Attackable {
And, the barrel shouldn't have moved diagonally, but it did.
class BarrelDraggable extends GameDecoration
with Movement, BlockMovementCollision, Pushable {
I think that your ColumnDecoration don't need have BlockMovementCollision, just adds a shapehitbox.
Why your barrel shouldn't move in diagonal?
I will fix this unwanted push.
I think that your ColumnDecoration doesn't need to have BlockMovementCollision, just adds a shapehitbox.
I replaced BlockMovementCollision
with ShapeHitbox
.
There are a lot of must fix
Why your barrel shouldn't move diagonally?
Because I want to make a tile-based game.
No, i'm sorry. The shapeHitbox that I said was adds a children collision:
@override
Future onLoad(){
add(RectangleHitbox());
}
Just add a collision without mixin BlockMovementCollision
I removed BlockMovementCollision
from with
and a onBlockMovement
method.
And I added your onLoad
's source code. I resolved the phenomenon of pushing it.
How can we help?
I want to add
ColumnDecoration
to the breakable feature in the example.When the player attacks the object, it will be broken.
I want a similar feature that can be attached to the
GameDecoration
extended class.And I want the feature which respawns again with time count.