September 22, 2017, 10:34:28 pm


Welcome to the Platino support forum!
We've got some huge Platino 4 updates coming very soon, so check back here next week.

July, 2017

Infinite Runner Player Movement. How to?

Started by Couds, September 08, 2015, 04:20:24 pm

previous topic - next topic
Go Down


Hey guys. this may be a silly question. but Im trying to do a infinite runner (My first video game) but I can't get the "player" to start running. >.<. I added my scene code to the attachments.

the scene.stepDelta method is called on every enterframe event. I tried to do a runner.state.vel.set(1,0) but didn't work, same with acc. If I use the pos runner.state.pos.add(speed*delta,0) the physics don't work.

Can anyone help me? Im really a new in game develop :/

Thanks to all ^.^
My code don't have bugs.. just random and erratic behaviour..


September 09, 2015, 12:24:38 pm #1 Last Edit: September 13, 2015, 11:50:58 pm by johngould
This should be better documented, I'm making a note to myself... but I don't see

Code Select
game.enableOnDrawFrameEvent = true;

From here.

In your code anywhere there. Are you setting it elsewhere? Please let me know. If there's no change I will ask Joseph (a core engineer who has far more experience with PhysicsJS than I do) to check this out.

- Peach :-)

*Edited: I wanted to add the link to the appropriate API in the docs.


Hi Peach.

I already have that enable in the index.js (where I create the Gameview). the stepDelta method is called. the problem seem to be in the physics, I'm have something wrong but I don't know what. if I change the restitution of the "Physics.body" almost work.

I create a repository in bitbucket with all the code. here is the link. thanks
My code don't have bugs.. just random and erratic behaviour..


Hey, just downloaded your code and I'm looking at it now.  I'll let you know if I can find an answer for you on this.

--John  :)


Hey, I just figure out what was wrong.. I create a behaviour and apply it to the runner body.

Physics.behavior('runner-constraints', function(parent) {
                var defaults = {
                    vel : {
                        x : 0,
                        y : 0
                return {
                    init : function(opts) {
              , opts);

                        this._vel = Physics.vector();
                        delete this.options.vel;
                    setVelocity : function(vel) {
                        return this;
                    behave : function(data) {
                        var bodies = this.getTargets();
                        for (var i = bodies.length - 1; i >= 0; i--) {
                            bodies.state.angular.pos = -0;

var run = Physics.behavior('runner-constraints', {
                vel : {
                    x : 0.0001,
                    y : 0

Thanks anyway. if you find another way port it too. =D
My code don't have bugs.. just random and erratic behaviour..


Nice, you beat me to it!  :D

I'm still getting the hang of PhysicsJS myself - it's a bit different from what I'm used to but very cool when you figure it out.  Thanks for posting that code!


September 14, 2015, 01:47:49 am #6 Last Edit: September 14, 2015, 02:29:21 am by Couds
me too Im starting with PhysicsJS my self. but is hard to find tutorials of the engine. Now im fighting with the camera :/ don't want to move.

  var transform_camera = platino.createTransform();
            transform_camera.duration = 1000;
            transform_camera.easing = platino.ANIMATION_CURVE_BACK_OUT;
            transform_camera.lookAt_eyeX = SOME_VALUE;

and nothing happen. I put that code inside a touchstart event. the event is fired but the camera doesn't move :S


Edit. seem that the camera problem was that I didn't set to TRUE the game.usePerspective;
My code don't have bugs.. just random and erratic behaviour..


September 14, 2015, 02:38:24 am #7 Last Edit: September 14, 2015, 02:40:59 am by johngould
Okay, so, you've hit on an EXCELLENT reason why we need to get our release notes done on Platino 3!  (Hint, hint, Peach and Joseph!)

One of the big changes we made was to set the default perspective of the game view to orthographic mode.  Someone will have to correct me if I'm wrong, but I believe in orthographic mode, the camera can't be moved.  So typically you would move the sprites and background and stuff around instead of moving the camera.

However, if you do need to move the camera around a scene, which is perfectly valid, just put this in your index.js file:

Code Select
game.usePerspective = true;

That will magically enable the camera movement you're trying to do!  We did add that to our camera sample, I just noticed here:, so I can confirm that that works.  Just be careful about moving around in the Z direction - that can result in some odd behavior since you're dealing with a seemingly 3D camera in a 2D world.  It's not a bug or anything, just not very intuitive behavior.  But as long as you stick to X and Y, you should be good.

--John  :-)

Edit:  Dang, man, you beat me to the punch again!  :P



I fix that. I update the new code. but When fixing the camera position to the runner position sometimes seem very laggy. can you look at the code?

My code don't have bugs.. just random and erratic behaviour..

Go Up