Search the Community
Showing results for tags 'constant'.
-
Hello, How might I apply constant movement using oimo.js such as would occur in an asteroid field - where no object stops moving? That is not the task, but best describes it. By the way I do have borders so the objects are contained. But even if I set no friction and a restitution of 1, no matter how I've tried to apply the impulse, I cannot keep to objects moving. There is no gravity in the scene. Thanks, DB
-
So how can I set random speed for every object, so the acquired speed will stay? Now I have defined speed as constant, but it also increases the speed of every object. SPEED = 3; this.enemies.forEachAlive(function(enemy){ enemy.body.velocity.x += Math.random(SPEED + (SPEED/2)); }); I tried first with Tanks -example style, where is defined max and min speed, but i didn't work.
-
So I'm currently trying to make a sprite that just moves around in a circle forever. I was using the example found here: http://examples.phaser.io/_site/view_full.html?d=physics&f=angular+velocity.js&t=angular%20velocity as a base. My code for creating said sprites looks like this: @map.createFromObjects 'PlatformLayer', 45, 'platforms', 0, true, false, @circPlatforms @circPlatforms.setAll 'body.allowGravity', false @circPlatforms.setAll 'body.immovable', true @circPlatforms.forEach ((platform) => platform.radius = (+platform.radius or 1) platform.rotAngle = +platform.rotAngle or 0 @game.time.events.loop 1, ((platform) => platform.body.velocity.x = 0 platform.body.velocity.y = 0 @game.physics.velocityFromAngle platform.rotAngle, platform.radius*32, platform.body.velocity platform.rotAngle = ++platform.rotAngle % 360 ), @, platform ), @In Tiled I assign a rotAngle (the current spot in the rotation) and a radius (the number of tiles I'd like it to cover). Unfortunately, I have no idea what I'm doing. I can't seem to get the sprite to move faster along the circle (increasing the speed parameter just seems to make the circle larger and body.angularRotation, body.angularAcceleration, and body.speed don't seem to help either), and I'm not at all certain how to ensure the radius in tiles (a tile for me is 32x32). Also, when this sprite gets to the end of a full rotation, it is not where it started, it's somewhere off to the top-left. I can't figure out how to determine why it's doing that. Overall, I'm just sorta confused about this whole ordeal. Any ideas?