Move a Sprite Manually?

  • Hi,

    Well I thought I knew, but obviously...

    I'd like to know the methods you can move a sprite manually (horizontally or vertically). This is for a Moving Platforms, although might have other uses.

    The Sine Behavior is out, as it has issues with smoothness at low resolutions when a Player is on it (I have another post on that).

    Until now I've used the Bullet Behavior, but this has it's own issues as it uses an angle to flip it's direction, in-turn mirroring the sprite about it's axis/origin.

    I was curious of the Custom Movement Behavior, but can't see how to use it in the Event Sheet - there's no online info of it implemented anywhere.

    I'd obviously like to keep Delta Time too, so that will be needed too to add to the mix.

    Thanks in advance.

  • Like i said in the other thread, you can use Bullet behavior without flipping or morroring. Here is an example:

    1drv.ms/u/s!Ap_-qxoGKbDcg1s41CT8fFnHvs2G

  • Thanks Kriand for the example, it was a good one. Although I'm a little confused with your code, the whole ID thing is confusing. But it's late and I'll have a further look tomorrow.

  • The ID should prevent a platform from colliding with a wrong box in case the tracks overlap. This is not the case in my example, but I did not want to ignore this possibility.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could use 8 Direction, or platform. All you do is on certain condition ACTION = IGNORE PLATFORM OR 8 DIRECTION SIMULATION.

  • After Trying Kriand's example file, which does a good job (thanks), I can see there are issues with the screen update/refresh again. The platform moves an amount then the player moves afterwards. They are not updated together and not in sync. This looks so rough, it's unusable in games.

    Unless I avoid moving platforms in my platform game, which kinda needs platforms that are moving to be a 'full' platformer (in my mind). My games gonna look rough.

    Pretty disappointed to say the least.

  • The logic to do moving platforms would ideally be:

    1. Move player

    2. Find the platform the player is on, if any.

    3. Move the platform, and move the player by the same amount if they were on it.

    But because of when the behaviors run it can end up being:

    1. Move player

    2. Move platform

    Or

    1. Move platform

    2. Move player

    Depending on their order in the engine. It’s not something you can control. That’s what can cause them to not be synced.

    The platform behavior does have logic to move with the platform it’s on, but it depends on which is moved first I suppose.

    You probably don’t want to create a platform movement entirely with events but that would give the most fine control of stuff. On the other hand, it can be tricky sometimes to move stuff with events or other behaviors in a way to keep other behaviors happy.

    In this case you probably can get away with it. So instead of using a motion behavior on the platform you’ll want to move it with events so we can do that ideal method listed above.

    Here’s some simplish events to do that:

    Global number onPlat =0

    Global number dx=0

    Player: is overlapping platform at offset (0,1)

    —- set onPlat to 1

    Else

    —- set onPlat to 0

    Start of layout

    —- platform set speed to 200

    Platform.x >400

    — platform: set speed to -200

    Platform x < 100

    —- platform: set speed to 200

    Every tick

    —- set dx to platform.speed*dt

    —- platform: set x to self.x +dx

    If onPlat = 1

    —- player: set x to self.x+dx

    Now that assumes just one platform that just moves to the left and right from 100 to 400.

    Multiple platforms could be done by saving the uid of the plat the player is on and only move the player by the amount that play moves.

    Also you can make the platform motion as complex as you like. Just move the player by the same amount.

  • After Trying Kriand's example file, which does a good job (thanks), I can see there are issues with the screen update/refresh again. The platform moves an amount then the player moves afterwards. They are not updated together and not in sync. This looks so rough, it's unusable in games.

    Unless I avoid moving platforms in my platform game, which kinda needs platforms that are moving to be a 'full' platformer (in my mind). My games gonna look rough.

    Pretty disappointed to say the least.

    Hey JayH extremely late post here. I came across your thread when i was searching the forum for something else. You're using C2, did you try using rexrainbow's ZigZag behaviour? That works pretty well for moving platforms, although im not sure it will solve the problem you're having.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)