R0J0hound's Forum Posts

  • If that doesn't work then I think there was a change in C2 that caused it not to work. However there should be a fix in the topic it came from as I recall.

    Alternatively this also works:

    mouse: left button down
    --- create dot at (mouse.x, mouse.y)
    
    for each dot ordered by dot.zindex ascending
    --- sprite: set angle toward (dot.x, dot.y)
    	system: compare distance(sprite.x,sprite.y,dot.x,dot.y)<sprite.bullet.speed*dt
    	--- dot: destroy
    	else
    	--- stop loop[/code:2r77i6tp]
  • You can do it with an effect. Maybe set color? and just set the red, green and blue parameters from events.

  • If they're the same no matter what computer you're on couldn't you just make the list beforehand and include it in your game?

  • Paster would only make a difference if webgl is used, and even then with one instance of the canvas it's not going to effect a whole lot.

    Had a look at the capx. Nothing stands out as a problem. For me the debugger eats up the most of the cpu so maybe you could just add a fps counter to your game/app to get a better idea of the perfomance.

    You're not running into an issue of drawing too much, at least not with 100 of your dialogs. Even the line drawing isn't causing much of a slowdown. I disabled drawing them and didn't notice much of a difference.

    The collision checks are caused by the "overlapping", "on object clicked" and drag n drop behavior. I don't really see any place you can reduce those in your capx. You could reduce the amount of checks if you did something like the following so the top dialog and it's container are checked for hover and click events. If the click is elsewhere then the rest of the dialogs are checked. This should reduce the normal cpu usage. One caveat is hover effects only apply to the top dialog, and you may want it to work with everything.

    pick top dialog
    mouse over dialog?
    --- do stuff
    
    on click
    	local number case=0
    
    	pick top dialog
    	mouse over dialog?
    	--- set case to 1
    		mouse over button1
    		--- do stuff
    		mouse over button2
    		--- do stuff
    	case = 0
    	mouse over dialog?
    	pick top dialog
    	--- set case to 1
    	--- move to top
     
    	case = 0
    	--- //clicked on empty space[/code:o6q4mgap]
    
    What the most likely cause for the slowdown is the high object count and the picking of events.  If you can reduce the number of times you have to filter the SOL for an object.  Not always possible but utilizing sub-events instead of picking from "all" can help.
    
    The first culprits of events that slow things down are nested loops.  In your "update canvas" function, it loops over each dialog and then each of it's children. One thing you could do to speed things up is to store the children's uids in the list so you can then use "pick by uid".  Picking by uid basically picks the object directly, whereas using a comparison casuses all the objects to be checked.
    A second idea would be to not store a list of the children but instead only store the uid of the parent.  This would require reworking your event sheet but the result is much simpler.  As a note if the dialog doesn't have a parent set the variable to -1.
    [code:o6q4mgap]local number endx=0
    local number endy=0
    local number parent=-1
    
    for each dialog
    --- set endx to dialog.x
    --- set endy to dialog.y
    --- set parent to dialog.parent
    	pick all dialog
    	pick dialog by uid parent
    	--- drawline from (dialog.x,dialog.y) to (endx,endy)[/code:o6q4mgap]
    
    That way each dialog is looped over once and it's connected parent is picked directly. should be much faster.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well first of all, have a look at the "pick closest" condition. It does exactly what your loop does. So you could do your above code with three conditions.

    Objectfinder: ischeckingfortarget is true

    System: For each objectfinder

    ObjectA: pick closest to (objectfinder.x, objectfinder.y)

    So now let's talk about what you want to do. So roughly this:

    Start

    Each finder pick closest obj and save it as finder.target

    Move finder to their target

    If the distance to the target is less than some distance

    Then go back to start and pick another close object but not the old target.

    What I'm not clear on is when the finder gets close to it's target and it picks a new one, do you want it to ignore just the last target or do you want to ignore all previous targets? Or do you want to do something else?

    I just re-read what you wrote, so I guess you want a target, once reached to be ignored until the finder gets X distance away.

    I guess you could filter away all the objects that are close to the target before finding the closest.

    I'd give your finder object a variable called target with a default value of -1. Then Your events could look like this:

    Finder: target = -1

    For each finder

    System: pick Sprite by comparison distance(Sprite.x,sprite.y,finder.x,finder.y) > 100

    Sprite: pick closest to (finder.x, finder.y)

    --- finder: set target to Sprite.uid

    For each finder

    Sprite: pick by uid finder.target

    --- finder: set angle to (Sprite.x, Sprite.y)

    --- finder: move forward 100*dt pixels

    For each finder

    Sprite: pick by uid finder.target

    System: compare distance(Sprite.x,Sprite.y,finder.x,finder.y) <100

    --- finder: set target to -1

    Edit: ninja'd

  • newt

    Not really. I mean you can think of it as a combination of sprites and tiled backgrounds when it's drawn, so as far as draw calls, maybe. In reality it's probably less, but that's not what's happening here IMO.

  • I'll have to look at your capx later when I'm home but here's a few thoughts:

    If webgl is enabled I'd still recommend using the paster object because the canvas has to be copied to a webgl texture every tick that it changes. And actually the text object does the same thing so maybe you could use Spritefonts instead.

    Actually if that is the bottleneck you can quickly check by setting webgl to off in the project settings. If the performance increases and the cpu usage goes down then I'd just leave webgl off, as it eliminates the need to copy the texture of the canvas and text instances.

    Another thought is unless you're clicking or constantly checking what the mouse is over shouldn't the collision checks per second be 0? I guess I'll see when I open the capx.

  • Pick by uid is the exception. It can pick any new object at any time. You can find some more details about top level events by searching for top level in posts I've made.

  • Have a look at the SpriteFont.TextHeight expression. If it's less than SpriteFont.Height then all the text fits in the box.

    To set the scale to fit all the text you could do an iterative approach with a loop. Basically it tries a scale of 1.0, sees if the text fits and if it does stop the loop. If it doesn't

    repeat 100 times

    ---> spritefont: set scale to (100-loopindex)/100

    --- spritefont: height > spritefont.textheight

    ------> stop loop

    Here's an example:

    https://dl.dropboxusercontent.com/u/542 ... t_fit.capx

  • 1) the bullet behavior would work fine.

    2) just set the bullet's speed angle of motion and gravity, but you could do whatever.

  • It should be everything, at least for the system and official plugins. If anything doesn't then that would be a good reason for a bug report.

    For third party plugins it depends if the author implemented that part or not. I know for example most of my plugins don't impliment saving and loading, but I guess that's on me.

  • Maybe something like this to save if you just want to save positions.

    Set array size to (Sprite.count, 2, 1)

    For each Sprite

    --- set array at (loopindex, 0) to Sprite.x

    --- set array at (loopindex, 1) to Sprite.y

    Then maybe this to load:

    Array: for each X

    --- create Sprite at array.at(array.curx,0), array.at(array.curx,1) )

  • Just use multiple layouts. No need to deal with xml or databases.

  • You could use a global variable I suppose. I don't know when you make it jump, so for example every second you could do this.

    Global number move=0

    Every 1.0 seconds

    --- simulate jump

    --- set move to 1

    --- wait 0.5 seconds

    --- set move to 0

    Move = 1

    --- set velocityX to 100

  • I can't open your capx atm, but the every tick event is where you set the starting X,y, and velocities. In what I typed about it uses a object called cannon's position and angle.