Gameplay degrades on iOS

RevengeanceRevengeance Member Posts: 10
edited March 2012 in Working with GS (Mac)
Hello there, my name is Rev and I'm a teacher. I've been working on a game for my students. It's a lot like old old megaman, meaning a running jumping shooting platformer. So far everything has worked great, except now that I'm testing on my iOS device there are stark differences between what is on my computer screen, and what is on my phone's screen.

For starters, my shoot button is set up like this:
I have a boolean attribute that is called "shoot go" which is set to 0 unless my shoot button is pressed.
The shoot button has a timer in it, and every 0 seconds it looks for touch to be pressed, when that happens it changes attribute "shoot go" to 1. Otherwise change attribute "shoot go" to 0.
My player actor then has a timer, also set to 0 seconds, in which is a rule: when attribute "shoot go" is true, spawn actor "laser" and it's set to spawn 19 (x axis) pixels away from the center of the player (so it lines up with the artwork.)
The laser actor then has two rules. First is "Move" direction is 2 (to combat gravity) speed is 1000, move type is additive. The second rule is a timer, which after 2 seconds destroys the actor (so it doesn't fly forever.)

(disclaimer: I know change attribute self motion linear x to 1000 would be better for the lasers, but then they fall because of the gravity in the scene, which is 1000. This way they arc.)

What this amounts to is when I press the shoot button on the computer my little robot produces a steady stream of laser fire. On the iOS device though something changes, and the lasers do not fire in a steady stream. When holding the button, the lasers seem to spread out and just sit an equal distances from each other. What this seems like is a frame rate issue, because the lasers are still being spawned, and they are still traveling, but they are only displaying and interacting where they are visible on screen.

Essentially, I could have my player actor standing in front of a monster, and I press the fire button, and the lasers spawn and fly, but the monster isn't destroyed (like he would have been on the computer, with the steady stream,) because the laser actors are sitting in a locked pattern. The stream, while being fired, has gaps.

I'm not sure if this is making sense. I hope it does. I am really stumped here.

Answers

  • RevengeanceRevengeance Member Posts: 10
    Wow, thanks for the speedy reply! Have any advice for me then? I also have another issue. I have two scenes, one is a test scene that is only 480x320, and they other is an actual level, and that's 12,000x320. When in the small scene, the lasers hardly seem affected by gravity, but in the larger scene they droop immediately. It's like the gravity in the larger scene is more intense. (I've checked, they're both set to Y 1000 in the scene's attributes.)
  • AsymptoteellAsymptoteell Member Posts: 1,362
    If you only have a few actors that should be affected by gravity, you should probably just give them an "Accelerate" behavior pointed down. If I'm remembering right, this will either directly cut down on performance issues, or will make it so that you don't need to constrain other actors in place, which definitely causes some performance problems.

    Asymptoteell
  • RevengeanceRevengeance Member Posts: 10
    Yes, I've thought of that but haven't given it a try yet because I'm lazy and would prefer to have large systems that the actors work within, as opposed to lots of individual rules they follow. It's a platformer, so I have the one player and tons of little monsters to shoot. I would add the gravity rule to their prototypes, but that would still be one more rule x50 in the scene. Is that better than having gravity as an attribute in the scene?
  • AsymptoteellAsymptoteell Member Posts: 1,362
    How are you keeping the other actors from falling with gravity?
  • RevengeanceRevengeance Member Posts: 10
    Turned off "Movable" in their attributes.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Also there is no need for the every 0 second timer to check for touch is pressed. Just take the timer out and make your rule
    When touch is pressed Change attribute to 1
    Otherwise
    Change attribute to 0

    If you have many of those timer constantly running like that its gonna kill performance. you definitely should not have any issues with making that type of game so I would say you just have some major optimization to do.

    Definitely Do the accel down on only the actors you need to be affected by gravity and shut scene gravity off.

    Make sure your constrains cannot do with a change attribute instead.

    Also make sure your art is only as big as it needs to be. If you have art files larger than needed for the actor size you may be pushing your art into a memory container higher than what is needed. Using more memory than needed is never a good thing.

    Hope it works out for ya.

    Cheers
    Aaron
  • RevengeanceRevengeance Member Posts: 10
    All right, I will try those things. My art is very small, as I went for a pixelated retro look. Any idea on why the gravity would behave differently depending on scene size though? Not knowing is driving me crazy.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2012
    Don't know about the gravity issue, but I've had major problems getting timers to work properly when moving from Mac to GameSalad Viewer on an iPhone to an iPhone with the app downloaded . It's to the point where I try to avoid timers (as @tenrdrmer suggested) or at least know that they are going to throw off the... timing... when I release my app. I've had to make some pretty severe updates to my apps to get them working again. As an example, I spawned a keyboard (26 actors) with a couple of timers. Everything worked great on the Mac and on an iPhone running GameSalad Viewer, but when I downloaded my own app from the App Store, I was surprised to see that it would only spawn about 8 of the letter actors. I had to rework the whole code. Frustrating, but it was a good learning experience.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RevengeanceRevengeance Member Posts: 10
    Good to know. I think I'll work it out so that I only need the one timer (to despawn the laser.)
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Also spawning/destroying is something else you should avoid when possible. Try to reuse actors off screen for the next actors coming up. What is not working right with gravity? If the scene is larger is could simply be that having gravity on everything even when its not needed is killing the device. and its just more noticeable in the larger scenes.
  • RevengeanceRevengeance Member Posts: 10
    The gravity issue is fixed by virtue of the scene itself no longer having gravity. How though, can I have an actor that shoots projectiles that doesn't spawn or destroy the individual projectile actors?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    this will show you how to recycle your bullets

  • RevengeanceRevengeance Member Posts: 10
    Thank you all so much for the help!
  • RevengeanceRevengeance Member Posts: 10
    Everything is working so much better now, especially the gravity and framerates. (The bullet quality DRAMATICALLY increased when I started recycling just 10 instead of spawning and destroying thousands. However, I'm running up against another problem that I'm not sure how to tackle:

    My player has a health bar, and I want it to have a maximum of 10 "HP." I've made it so that things that award HP only do so when the attribute game.HP < 10, but for some reason if the player does something that awards HP it doesn't add health, but makes the player immortal. Definitely no the desired result. Any ideas? Thanks again!
Sign In or Register to comment.