Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Xinbei

Pages: 1
Interesting Discovery!!!

I was unable to figure how to set the step size to float, however; I was apple to simulate 16.66 steps by using an update event that cycles and changes the step size constantly between 16 -> 17 -> 17 (which averages out to 16.66). This allows it to essentially match the draw rate and seems indistinguishable to the player. Almost all jitters due to movement has disappeared except for some Y axis acceleration jitters due to gravity (I suspect these can be solved with a combination of actor smoothing and a invisible tween in/out camera).

I'm still early in the testing phase of this new strategy and I suspect there may be many draw backs but have yet to identify them. I still want to find how to set the update step to 16.66 so I am still actively looking for any insight into how to use the Stencyl API in that direction.

But, for now I think this is the best measure to alleviate jitters and I may make a post later detailing the process and findings to hopefully generate more discussion and see what information the community has on this strategy.


- This strategy essentially renders the game at 60UPS that lines up with the DRAW and can be increased to 120UPS by subdividing the steps
- This strategy's noticeable drawback is that it counts time very inaccurately in the UPD event and I've yet to test how it affects the do every/after events
- I am quite the novice when it comes to coding so I suspect that there is a plenitude of better solutions but this one is the best I've come up with after many many hours of testing and experimenting

Potential Issues (Edit)

- [FORCES] I don't know how actors with acceleration and forces will work with this implementation because I've notice that some Y axis gravity behavior exhibit a new variety of jitters (single direction jitters)
- [DESYNC] I don't know how exactly dropped frames will effect this method. If a frame is dropped, will the next frame be drawn before the time allotment of the dropped frame? If so this may render this method unusable

I have, unfortunately all of them still cause jitters (even the smooth camera). I've also tried previous versions of stencyl and all of them have the same issue. I really want to figure out what the Box2D Timestep section of the stencyl API can do but I lack the technically knowledge on how to implement it.

Thank you for the suggestions

I tried testing rounding player position after every update step, however; the screen remain jittery. The player moves by setting X/Y speed if Left/Right keys are down. I suspect the issue isn't having decimal positions but instead having inconsistent distance between draw frames due to the 6.77 MS difference between UPD and DRW.

I've also tried to create an invisible actor that follows the player (using tweening in/out to follow). This works well until the player and camera reaches a steady distance and the jitters return.

I have read the thread and that is how I learned how to use the basic STEP_SIZE adjustment but it only shows how to adjust the STEP_SIZE to and integer rather than a float (I've tried to place 16.66 after engine.STEP_SIZE and it returned an error saying floats should be integer)

I have also found a few things that may help resolve this issue in the stencyl api but I do not know how to interpret/implement these codes (I tried dozens of combinations of these terms and setting to =16.77 or 1/60 but alas none of them works and I can't find a beginners guide on how the syntax work for these functions specifically)



dt : Float

dtRatio : Float

inv_dt : Float

Instance Methods
set(step : B2TimeStep) : Void

I may be grasping a straws but it seems like "dt" is the time between steps and that it can be a float.


I should also add I've created a camera that only moves in whole integers in the draw frame, while this resolves the background jitters (and jitters for any actors where X/Y speed = 0) it significantly jitters any moving actors because those actors still move a inconsistent rates. The closest I've come to solving jitters is setting step size to 16 or 17 but it gives consistent freezes every second because of the 0.33 MS difference.


My platformer has a lot of jittering when moving that I think is caused by the difference in FPS and game step size, how can I set the game step size to the same as the draw step size?


I am making a side-scrolling platformer and I am getting background jitters when I tie my camera to the player movement. I found that this is likely because the player's position is updated every 10ms the game is drawn every 16.66ms. The player will move at a steady speed but due to the desync in draw and update, the player's position will be drawn at a inconsistent rate. When I tie the camera to the player to keep the player at the center of the screen, it will cause the camera to be moved at the player's inconsistent drawn position causing the background (and all other actors) to jitter.

EX: Player that moves at 30 SPD will update their position at 0 -> 3 -> 6 -> 9 -> etc but their drawn position will draw at 0 -> 3 ->
9 -> 15 -> 18 ->etc

Attempted Solutions

1. I have tried to create a smooth camera that guess where the player should be (the camera moves at smooth rate based on player move speed) but this causes any moving actor (enemies and player) to jitter because they still have the issue where their draw and update rate a different.

2. I have tried using the smooth actor extension, however it still has minor jitters and heavily desyncs the actor hitbox from its animation.

3. I have tried tweening the camera but it seems like tween also updates at 10ms and has the desync issue.

4. I have tried setting the max framerate to 50FPS and the step size to 20ms but this makes the game feel sluggish and jittery still (perhaps from the 50fps?)

Possible Solution (Need Help)

I believe if I can make the game step the same as the framerate, there will be no more jitters. I have tried setting the game step to 16ms and 17ms and the jitters were gone, however, once every second there will be a lag where the draw and update desyncs. I know I can't set GAME_STEP to a float (16.66ms) but I see on the BOX2D manual that it is possible to set the physics update to 1/60 seconds
float32 timeStep = 1.0f / 60.0f;
Is this possible to implement to stencyl and if so, what should I put into the code box?

Additional Notes (Edit)
- Player actor moves using steady X/Y Speed blocks when player presses L/R Keys
- Player actor has no friction
- Jitters persist even if there is no gravity
- Game is played on the desktop version

Thanks Merrak, if you have the spare time  I would greatly appreciate the extension and I'll help you in any way I can. In the meantime, I'm going to look into the reflect class and your XML iterator to see if there's any option there.

Thanks for the responses,

Seems like there's no easy way to convert JSON to a map attribute. Look like my options at this point are:

1. Convert the JSON to a CSV and use the text split function to convert CSV into a map somehow (not ideal since I'll have to create a different split event for each type of JSON)

2. Convert the JSON to XML and use the XML API in haxe to iterate over every single node and somehow setup  a map during the iterations

3. Hire a coder who knows how to use haxe to write me a JSON to Map attribute converter (any suggestion to where I can find  and hire a coder for this?)

None of these options are ideal and hopefully in the future Stencyl will have a direct converter for JSON to map attribute like in Game Maker Studio 2. I think JSON is incredibly useful and convenient and if I could convert one into a global map attribute it would allow me to easily create a complex yet accessible database for my games.

If anyone has any other work around method, please let me know I would greatly appreciate any suggestions that would allow me to convert JSON or even XML into a map attribute


I want to convert JSON strings/files into map attributes in my game. I have only used drag and drop thus far but I have figured out how to use the code block to parse a JSON string. I set the parsed JSON result as an anything attribute. My problem is that I can't convert the anything attribute into a map nor can I use map blocks on it despite it looking exactly like a map when I print it.

 How can I either directly convert the JSON into a map with nested arrays/maps or convert the Anonymous Structure from the parse function into a map?

An example of a JSON I want to convert into a map is:

Code: [Select]
  "apple": {
    "value": 10,
    "health": 15,
    "tags": [
  "lemon": {
    "value": 5,
    "health": 10,
    "tags": [
  "ham": {
    "value": 50,
    "health": 50,
    "tags": [

Attached is the block I've been trying and the results of printing the anything attribute.


Edit : Solution:
It appears that I made two errors in example  2.
Error 1: I forgot to calibrate the list
Error 2: "For each actor in region" doesn't work with simple actors but when I switch to normal actors it works as intended.

     I want to add all actors (as text) in a specific regions into a list by using the "For Each Actor in Region" block but whenever I try, the game crashes.

     In the first attached image I simply increment a counter by the number of actors inside the region and everything works as intended. Unfortunately, in the second attachment when I try to add the "actor inside region" as text into a list, the game will crash.

     I have searched the forum for similar issues and have found two threads with similar issues but neither are resolved. I have also found a post regarding "For Each Actor on Screen" in the issue tracker and I'm wondering if its possible that my situation might be related to it.

Thanks in advance for your help!

Ask a Question / Re: [Solved] How do you add Map/List to a Map Attribute?
« on: September 09, 2016, 02:13:42 pm »
Thanks Justin, my maps are now functioning as intended!

Ask a Question / [Solved] How do you add Map/List to a Map Attribute?
« on: September 09, 2016, 01:46:57 pm »

     I would like to know if it is possible to add a map attribute or a list attribute (maybe even a 2D list attribute) to a map attribute as a value to a key. I am under the impression that it should be possible since the Map Attribute page of the Stencylpedia contains images of what seems like maps inside other maps. However; from my own testing I found that when I attempt to add a list/map to a map using the "set key to value" block, the game will crash.

Am I missing something obvious or is there a specific procedure for how this can be done?

Thank you in advance for any input this would be very helpful for my game!

Resolved Questions / Re: How to Import Text Files Into Map Attributes?
« on: September 01, 2016, 10:40:43 pm »

Resolved Questions / [Solved] How to Import Text Files Into Map Attributes?
« on: September 01, 2016, 08:52:48 pm »

How do you import text files into a map attribute without using any extensions?

I have tried adding text files into a map attribute by using the "Import from text file..." button but I can't  get it to work. I have tried formatting the txt. file in various formats such as: "key:value" or "key value" on each line but no matter how I organize the text file I can't submit the txt. file into the map attribute.

Thanks in advance for your input!

Pages: 1