AllanR's Recent Forum Activity

  • I don't think off screen objects get rendered, so there is not much of a performance hit to have them around (but it is still having to loop through all of them every tick and calculate their position).

    If you delete all the ones off screen you may also be deleting new ones you are setting up to scroll onto the screen. So, you may want to do something like Sprite.X < -100 then sprite Destroy.

    (obviously you have to factor in the width of the platforms to make sure they are completely off the screen)

  • well, I recreated your project... and I could not get it to fail. It worked just the way you wanted... and I tried several variations.

    I added Drag and Drop to the blocks so I could move them around to see how they were stacked.

    I also added an animation - grey for the bottom layer, white for the top, to help see which blocks are which.

    And I added a text box at the top of the screen to display the block coordinates when you click on it or move it.

    My first thought when I started was that your sort routine was not working the way you expected. You sort on arrayZ, but the 25 blocks that make up the upper layer could display incorrectly (like in your picture) if you don't also sort them by arrayY - because the blocks with a lower arrayY need to be behind the ones with a higher arrayY. But, like I said, it worked fine for me when I tried it.

    I am using the latest version of C2, so it could be an issue with an older version - where the ambiguity of just sorting 25 blocks with the same arrayZ gives a random order or something like that...

    anyway, try my version and see what happens. you can get it at:

    http://www.rieperts.com/games/forum/Blocks.capx

    In my version, if you press A it creates another set of blocks using loops rather than the array. But that way also worked as expected.

  • For sprites that you want to rotate to various angles (like your SpikeGunSpike object), zero degrees is pointing to the right. Your object is drawn pointing straight up - so it is always 90 degrees off from where you want it to point.

    All you have to do is open your object in the image editor, click the button at the top that says "Rotate 90 clockwise". Then when you rotate the sprite it will be pointing in the direction you want.

    (your code works fine, it is just the image that is off)

  • I agree, tenbolts, your game looks great - and runs pretty smoothly on my iPhone 5.

    Ashley, well, that is good to know, and doesn't surprise me too much - because everything else in Construct2 is "very carefully designed".

    It is possible that my results were more imaginary than anything else. I started with someone else's project that was not working very well, and I cleaned up the code, added parallax scrolling, completely changed the way the background was looping, etc. By the end it was working much better - but still not perfectly smooth. Some day I want to try Cocoonjs (and other wrappers) to see how much that helps (or not)...

  • I was doing some testing along these lines a month ago and figured it was mostly garbage collection to blame.

    Things did seem to improve when I made as little garbage as possible.

    What I did was create all objects before the game started, and never destroyed ANYTHING. I kept everything I wasn't actively using just off screen, then moved them into position when they were needed, and moved them back off screen when they had been "collected". That way, while the game was running, no new memory was being allocated to create objects, and none was being released to destroy them.

    I didn't test on very many devices, and haven't had time to dig any deeper into it since then, but it definitely seemed to help!

  • Thanks! this is very helpful.

  • you could use a variable "Position" to hold the current index. Have it start with a value of 0 (at the top of the array, or bottom - depending on how you want to look at it).

    Then if you press the down button, subtract 1 from "Position, then check if it is less than 0, if so set it to 9.

    If you press the up button, add 1 to "Position", then check if it is greater than 9, if it is then set it to 0.

  • The way I usually handle that is to use an invisible sprite for the player - to keep instance variables, the position on screen, and keep all the events as simple as possible. Then you can pin any sprite you want on top, change animations as necessary, etc...

  • jhonathan Ibanez, I just checked out your website now. The Zombie game is very good! The graphics look fantastic. I guess you know the Credits button and Options button don't seem to do anything...

    It also took me a while to figure out that there were power-ups available. I like the way you use brains as a type of radar to show that zombies are coming.

    Very good job!

  • jhonathan Ibanez, as far as I know you can only up-vote comments on tutorials and places like the official blogs, and download pages. Not in the forums.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • rexrainbow, well, I played around with your version a little more.

    I took the dictionary out of the sprite. Made the Sprite global, made the dictionary global, put the dictionary back in the sprite, re-ran the project, and then the dictionary appears to be persistent now...

    (setting the dictionary global while it was in the sprite did not work)

  • Yeah, I just saw in yours that the dictionary is destroyed when it is in the containing sprite...

AllanR's avatar

AllanR

Member since 21 Nov, 2013

Twitter
AllanR has 23 followers

Trophy Case

  • 11-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Popular Game One of your games has over 1,000 players
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

20/44
How to earn trophies