velocity of a body

3 views
Skip to first unread message

I am Nobody

unread,
Sep 23, 2009, 5:23:52 PM9/23/09
to Mekanimo
Hi mekanimo developers,

first, sorry for my bad english, I am not a native speaker :)

I would like to change the velocity of a body at the runtime. I know
there is something like
<code>
circle.bind(KEYDOWN, system.evtHandler, key.LEFT_ARROW,
ADJUSTVELOCITY, **{'vx': -2})
</code>
but I want to change the velocity in manner
<code>
circle.velocity = (2, 0)
</code>

Is it possible?

thanks for help
a nobody

Fahri

unread,
Sep 23, 2009, 6:00:23 PM9/23/09
to Mekanimo
circle1.bind(KEYDOWN, system.evtHandler, key.LEFT_ARROW, SETVELOCITY,
**{'vx': 2, 'vy': 0})

I am Nobody

unread,
Sep 23, 2009, 6:19:44 PM9/23/09
to Mekanimo
Hi Fahri,

<code>
circle.bind(KEYDOWN, system.evtHandler, key.LEFT_ARROW,
ADJUSTVELOCITY, **{'vx': 2})
</code>
and
<code>
circle1.bind(KEYDOWN, system.evtHandler, key.LEFT_ARROW, SETVELOCITY,
**{'vx': 2, 'vy': 0})
</code>
both have the same effect, because both uses "vx" but not "d_vx" :)

I am writing a platform game with Mekanimo, so I must adjust the
velocity depending on if the character is on the ground or not etc. So
I need something like:
<code>
if (body.isOnGround()) {
set the velocity X
} else {
set the velocity Y
}
</code>

thanks
a nobody

Fahri

unread,
Sep 23, 2009, 6:36:20 PM9/23/09
to Mekanimo
Assuming that you already defined the isOnGround function:

def setVelocity(event, source):
if source.isOnGround():
source.vx = 2
else:
source.vy = 2

circle1.bind(KEYDOWN, setVelocity, key.LEFT_ARROW)


For more information about behaviors please see

http://mekanimoquickhelp.s3.amazonaws.com/modelling/behaviors/index.html

I am Nobody

unread,
Sep 23, 2009, 6:55:53 PM9/23/09
to Mekanimo
Hallo Fahri,

thanks for your help. Why didn't you linked the above URL in
mekanimo.net? That was what I am searching all the time.

best regards
a nobody

Fahri

unread,
Sep 23, 2009, 7:01:00 PM9/23/09
to Mekanimo
I will fix it tonight.
Reply all
Reply to author
Forward
0 new messages