Guizmus's Recent Forum Activity

  • Hey !

    I wanted to help, but having the free version limits blocked me in the debug process. I think the problem comes from the event "every tick -> set animation to check from the beguining". If I was the computer, I would put the first frame every tick because of this.

    I think you should create a function for this, function taking only few params : animation name, UID of the player (or not, you have only one), ... and call this function instead of setting "check".

  • The global question, "add behavior at runtime", has a simple answer : no, at least impossible right now with C2. In most case, behavior can be enabled/disabled, but not in your particular case.

    I see only 2 ways of doing this, both requiring maybe quite some implementation, depending on your project/project size.

    The first one would be to use families, and have 2 objects in it : one with the persist behavior, the other without it. You could replace all the occurence of your pseudo-persisting object by the family in the events, and you would have to "transfer" the datas from the persisting object to the non-persisting one (or the other way) when you want to change the persist behavior.

    The second one would be to use the load system. Every object that is savable has a "toJSON" function, letting you store your object in a string. There is also a "loadFromJSON" function. So you would have to remove the "persist" behavior, and save/load at each start/end of layout, depending if you want the object to persist or not.

    I would personally try to use the second options that seems more... implementable whatever the project.

  • Hey !

    There are 3 things that you should do if you want this to work :

    1/ right click on the 6th event (the one with the 4 angle tests), and make it an "OR" block, because as it is, it will only trigger if all the conditions are verified, witch isn't possible.

    2/ You have to have at least 2 animation frames. In the capx you linked, the animation is only in 1 frame !

    3/ If you want to manage the animation frames like this, you have to set the animation speed to 0, or it will play the animation. By default (and in your capx), it is set to 5 frames per seconds. So even if you change the frame to 0 (and if you have multiple frames, cf 2/), if will play the animation to its end, and redisplay the 2nd frame in 0.2s.

    I had more things to tell on your capX :

    • carefull, objects you delete in the layout will stay in the project. You have to delete them from the project file system (the frame on the top right by default in C2)
    • Try to have more meaningfull names for your sprites than "Image5", "Sprite", or "Sprite2", it will help you a lot as your project grows.
    • don't repeat the "rotate" action like this. Imagine you have to change how you rotate in the future, or if you decide that it won't be 1 rotation, but a full animation (rotation speed, acceleration, blink when rotating, ...). You would have to do the "rotation" feature 4 times (or more if you use other controls). Instead, call a "function" witch will perform the rotation, like this :

    <img src="http://guizmus.fr/captures/c2/aide.JPG" border="0" />

    I didn't change the way you capture the inputs, but you'll notice that this way let me move the "resize the white sprite" event inside the function, instead of being performed every tick. This is of no impact in a test like this, but in a project, try to evaluate the least possible number of things every tick, this is the best way to keep your framerate around 60fps.

  • Hey,

    Nice original case :)

    The question is about the method to store, yes, but mostly access the data.

    The text storage you are using is fast, and you should keep it in my opinion, for low number access (1-100/sec).

    If you need to pull a lot of data at once, like a thousand names in a tick, I would try to go for a database. SQL could help select the right names, and give you back a list in the same format (1 name per line) but you could just use ALL the names, and not seek the first, then the second, ... effectively speeding the algorithm a lot. (explode is a lot faster than 1000 seek ^^)

    But isn't there another way to use/reuse the names ? Why do you have to pull thousands of names at a time ? Could you imagine load those 1k names over 1 to 2 seconds, displaying a loading bar during this ?

  • There isn't any "join capx" function that I know of, mostly because it would be impossible in the generic case (how do you merge 2 layouts ?

    Best way to do it though is to open both capx in C2 (same instance of C2 of course), copy all the missing object from the first capx to the second one, copy/paste all events (or import event sheet), and do the same for the layouts. This will let you choose how the merging should be done.

  • set Angle is quite simple to understand.

    When you have a sprite selected, you see handles to resize it, and also a center point, with a handle on its side, to rotate the sprite. Basic orientation is 0�.

    If you set another angle on the sprite, it will rotate around its center, the origin point, witch you can change in the animation editing interface (dbl click on the sprite). Be carefull, there is a different center for each frame of each animations !

    How to implement the mats in C2 ? Depends how your "car" is built. If it's, let's say, 1 sprite for the body of the car, and 1 sprite per wheel, you should put those in a container.

    In the event sheet, I would create a function "car.move" (with a direction and a speed maybe ? Everything depends on your implementation). In this function, I would put some action on the car wheel sprite, "set angle to dt*car.speed*360/(3.1415*Sprite.width) + wheel.angle". Of course, you would have to change car.speed, Sprite.width and wheel.angle with the right variables, depending on the name of your objects and the behavior you use to move the car (how the speed is store)

  • You know, you should try the help people give you, especially when they are the developers of the program you are using.

    Just read this, as Ashley suggested.

    Timescaling

    A really cool feature in Construct 2 is timescaling. This allows you to change the rate time passes at in the game, also known as the time scale. You can set the time scale with the system Set Time Scale action. A time scale of 1 means normal speed. 0.5 means half as fast, and 2.0 means twice as fast. If you set your game's time scale to 0.1, it's going ten times slower but still smoothly - a nice slow-motion effect!

    Timescaling works by changing the value returned by dt. This means behaviors are affected, and any movement using dt. If you don't use dt in your movement calculations (like the first event above) the motion is not affected by the time scale! So to use time scaling, you simply have to use dt properly in all movement.

    Pausing

    You can set the time scale to 0. This stops all motion. It's an easy way to pause the game. Set it back to 1 and the game will resume.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Let's do some maths then !

    Length = Pi*Sprite.width*rotation(in �)/360

    So if you have the distance (dt*speed), then you have the rotation :

    Rotation = dt*speed*360/(Pi*Sprite.width)

  • rexrainbow

    I know creating copies of a built-in plugin or behavior is bad, I don't suggest you do it at all, but you know this a lot better than me.

    I spent some more time inside this plugin code though, and I don't see any way of doing what you describe with the core plugin without adding any javascript.

    Of course, creating a "text_ext" behaviour that would overwrite the draw function could do the trick too, but I have hard time finding a good way to store texts and color in the behavior parameters.

    There seem to be another way though, by creating a plugin that would automatically create N text objects and manipulate himself, each text object being of one color only. This would require, for what I know, to link the 2 object types at the start of the layout (a little like this plugin) so the "multicolored text" would know what to create. This could be impossible to propagate the Pin behavior though, no idea, you may know better.

    Sorry if this didn't help, I tried my best ^^

  • Hey,

    The code of the text plugin doesn't seem to enable such a behavior. Only once color is saved in the object, the only function setting the color is overwriting it, and it is only used 2 times in the whole object : savetoJSON, and draw, witch fills the whole text with the selected color. Sounds like this needs a specific plugin for such a behavior, or multiple texts :/

  • Hey,

    You can try to modify the behavior, but there is no real need for this. Instead, just set the "default controls" to "No" in the behavior properties. In your event sheet, use the "Simulate contol" action on your sprite.

    For example, in case the "up" key is down, you can simulate "up" and "right" controls, moving in diagonal.

    The problem with this is that you will only move on the perfect diagonal (45?). If you want to move faster on the X axis than on the Y one, you can add a second 8 direction behaviour on the sprite, simulate its controls too, and set its speed differently, so one behaviour moves the sprite on the X axis, the other on the Y one.

    (I'm not a pro on isometric movement, but this seemed to do the trick for me)

  • Hum, just add this pin on the letters sprites.

    <img src="http://guizmus.fr/captures/c2/capture4.png" border="0" />

    By the way, don't destroy/redraw letters every tick ! Put this in the start of the layout.

    Same goes for the text "buffer", don't keep the text object, use a variable.

Guizmus's avatar

Guizmus

Member since 26 Mar, 2013

None one is following Guizmus yet!

Trophy Case

  • 11-Year Club
  • x4
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies