TwelvestoneFlash

flash/air app accelerometer ball bounding to stage area?


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
derrickito
 
2011-11-04

so im doing some flash development (for iphone specifically right now), accelerometer ball is being controlled via the tip and turn of the phone. rolling it around the stage. im trying to limit it to the stage viewable area (320x480) so that you can't lose the ball off the screen, stopping it and rolling it along the edge. as is right now the ball quickly rolls off the screen never to be found again off in the ether

anyone smartypants enough to modify this below code to bound this to the stage area? i'm getting stuck

import flash.sensors.Accelerometer;
import flash.events.AccelerometerEvent;
var acc:Accelerometer = new Accelerometer();
acc.addEventListener(AccelerometerEvent.UPDATE, update);
var tx:int = 0;
var ty:int = 0;

   function update(e:AccelerometerEvent):void
{
    tx = e.accelerationX * 100;
    ty = e.accelerationY * 100;
}

this.addEventListener(Event.ENTER_FRAME, loop);
function loop (e:Event):void
{
    ball.x +=((ball.x + tx) - ball.x) * 0.3;
    ball.y +=((ball.y - ty) - ball.y) * 0.3;
}
derrickito
 
2011-11-04

what the fuck do you use for code tags around here? bah

Stinky
 
2011-11-04

You could always click on the help link, dummy k

derrickito
 
2011-11-04

i didn't see a helplink? i see a link to markdown now that im looking at it. and they say wrap everything in `'s. doesn't seem to work?

Stinky
 
2011-11-04

Jesus, dude. It's like helping a retarded uncle, I had just edited your post to make it work and you screwed it up k

(quote me to see the source code for this post)

function fnord() {
  console.log("23 skidoo!");
}

And for inline code the backticks work just fine.

derrickito
 
2011-11-04

fack that. i just stuck in linebreaks.

your code view markup is too complicated k

derrickito
 
2011-11-04

i had no idea you were in editing it. angry computer guy

Stinky
 
2011-11-04

Seriously? You can't figure out how to put three backticks on a line? I love ya, derry, but you're a tard k

(that said, when I start providing hosted forums I'm deffo going to have a wyswig editor)

arigato
 
2011-11-04

<blink>

derrickito
 
2011-11-04

well now that's looking pretty. good work team.

in the meantime, i think i got my question answered on YH

    ball.x += (((ball.x + tx) - ball.x) * 0.3) % stage.stageWidth;
    if(ball.x > stage.stageWidth) ball.x = stage.stageWidth;
    if(ball.x < 0) ball.x = 0;

    ball.y += (((ball.y - ty) - ball.y) * 0.3) % stage.stageHeight;
    if(ball.y > stage.stageHeight) ball.y = stage.stageHeight;
    if(ball.y < 0) ball.y = 0;
derrickito
 
2011-11-04

Originally posted by Stinky

Seriously? You can't figure out how to put three backticks on a line? I love ya, derry, but you're a tard k

(that said, when I start providing hosted forums I'm deffo going to have a wyswig editor)

i've been using forums for years, and i've never seen that convention. im not a bonehead, it's just not written out at all in the doc that you linked to. and i don't see anything labeled "help" on the twelvestone page here anywhere

http://daringfireball.net/projects/markdown/syntax#precode

that section shows nothing about 3 backticks. it might make sense to you since you put it all together, but average joe (who works on the internet every day for 12 years) it wasn't clear. i looked around

chalk it up not to a tard, but to it not being clear at all. im not trying to be difficult (quite the opposite), just trying to easily post some code and there was no easy way to do it. there's a case study on usability k

derrickito
 
2011-11-04

shaboink. found it. http://daringfireball.net/projects/markdown/syntax#code there is a link for "code blocks" on that page, which i assumed was for showing code, and for "code" that i missed because i thought i already was at it.

retarded is having to read a 30 page document to figure out how to post code to a forum k. why not just use bb tags or easier, html?

derrickito
 
2011-11-04

hey, let's all hit our heads against the wall a few times?

rogue_designer
 
2011-11-04

Originally posted by derrickito

hey, let's all hit our heads against the wall a few times?

I have to do that all day at work... I'll pass.

Also wavey

arigato
 
2011-11-04

:beer: :sad:

Stinky
 
2011-11-04

Originally posted by derrickito

retarded is having to read a 30 page document to figure out how to post code to a forum k. why not just use bb tags or easier, html?

BBCode is fucking slow and brain dead, that's why k

That said, I am planning on putting in a better "formatting instructions" thing. One more like the one that github uses. Still, a web dev that doesn't know markdown is kinda funny.

persist
 
2011-11-05

Is someone trying to port pinball to air?

cause...

I don't think you can do that.

:markdown removed by barn:

arigato
 
2011-11-05

Originally posted by persist

Is someone trying to port pinball to air?

cause...

I don't think you can do that.

:markdown removed by barn:

+1

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

flash/air app accelerometer ball bounding to stage area?