Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

Kaboom.js How can I change the direction of a sprite when he hits a wall?

Guelprix
Guelprix

As I was coding along with Ania Kubow´s Mario Tutorial, I noticed that the goomba will get stuck, if he walks into a wall. I wanted him to change his walking direction, if he hits a wall or a pipe. Tried it out my own first, but doesn´t seem to work that way :/(commented out line 207-213).
Thanks for your help

1 year ago

Voters

Comments

TopNew
1
Coder100
Coder100

Did you miss some parts of the tutorial?
There should be code like this:

collides("dangerous", "wall", (d, w) => { d.dir *= -1; });
1 year ago
1
Guelprix
Guelprix

@Coder100
i already tried that one but the goomba does not move at all

1 year ago
1
1
Guelprix
Guelprix

no everything else is working well

@Coder100

1 year ago
1
Guelprix
Guelprix

but is there a possibility that d.dir is not defined and
doesnt work for this reason?

@Coder100

1 year ago
1
Coder100
Coder100

@Guelprix
yeah, you didn't define it

1 year ago
1
Coder100
Coder100

maybe you can invite me and I will fix it for you

@Guelprix

1 year ago
1
Guelprix
Guelprix

i dont know how to I´m new to coding could you explain me how to do it?

@Coder100

1 year ago
1
Coder100
Coder100

click the invite button

@Guelprix

1 year ago
1
Guelprix
Guelprix

invited you if you are making any changes could you add a comment on what you did that would be very helpful

@Coder100

1 year ago
1
JudithNelson
JudithNelson

@Guelprix
did you ever get this sorted? I am new to kaboom and having the same problem, collision event plays for ever

3 months ago
Load more