Open netzerodash opened 10 years ago
If it is possible for you to provide a short reproduction of the problem, it will make any bug fixing a whole lot easier.
Thanks for using and enjoying the Extension :)
I've initialized this object at first
tireMat = new StandardMaterial(); tireMat.fragmentShader = new TextureFragmentShader(); tireMat.textures[0] = Texture.fromBitmap( new Bitmap(new Tire),false,false,Starling.current.contentScaleFactor );
tireL = new Shape(); tireL.graphics.lineMaterial( 5 , tireMat );
tireL = new Shape(); tireL.graphics.lineMaterial( 5 , tireMat );
when user touch on stage, the engine will draw the line
1st step :: moveTo ( when touch was began)
tireL.graphics.moveTo(l.x,l.y); tireR.graphics.moveTo(r.x,r.y);
2nd step :: lineTo ( when touch is moving)
tireL.graphics.lineTo(l.x,l.y); tireR.graphics.lineTo(r.x,r.y);
3rd step :: (when the end of touch)
stop draw line
When the user touch again, it's will start on 1st step and then 2nd step. But It's returned an error like this
RangeError: Error #1125: The index 1236 is out of range 1234. at starling.display.graphics::Stroke/addVertex()[/Users/mpz/Documents/Mobile Apps/MyMarketsApp/Starling-Extension-Graphics/src/starling/display/graphics/Stroke.as:88] at starling.display::Graphics/lineTo()[/Users/mpz/Documents/Mobile Apps/MyMarketsApp/Starling-Extension-Graphics/src/starling/display/Graphics.as:415] at Main/drawLine()[/Users/netzerodash/Desktop/AlwaysOn/Flash/BMW/iPad/Main.as:159] at netzerodash.assets::Cars/enterFrameHandler()[/Users/netzerodash/Desktop/AlwaysOn/Flash/BMW/iPad/netzerodash/assets/Cars.as:142] at starling.events::EventDispatcher/invokeEvent()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/events/EventDispatcher.as:141] at starling.events::EventDispatcher/dispatchEvent()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/events/EventDispatcher.as:112] at starling.display::DisplayObjectContainer/broadcastEvent()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/display/DisplayObjectContainer.as:375] at starling.display::Stage/advanceTime()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/display/Stage.as:77] at starling.core::Starling/advanceTime()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/core/Starling.as:380] at starling.core::Starling/nextFrame()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/core/Starling.as:369] at starling.core::Starling/onEnterFrame()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/core/Starling.as:568]
You initialize tireL twice?
tireL = new Shape(); tireL.graphics.lineMaterial( 5 , tireMat );
tireL = new Shape(); tireL.graphics.lineMaterial( 5 , tireMat );
but not tireR? Or is that just a copy paste error? :)
Unfortunately, I cant dig deeper into this, due to time constraints. I will get back to you on this, though,
Ok, I had some time to look at it, and yes, there is a problem. On it.
Now, it should be fixed. The following gives a surprisingly simple way of drawing geometry :)
private function onAdded ( e:Event ):void
{
bg = new Image(Texture.fromBitmap(new LandscapeBMP(), false));
addChild(bg);
shape = new Shape();
shape.graphics.lineStyle(3, 0xFFFF00);
addChild(shape);
addEventListener(TouchEvent.TOUCH, onTouch);
}
protected function onTouch(event:starling.events.TouchEvent) : void
{
var touch:Touch = event.getTouch(this);
if ( touch == null ) return;
if(touch.phase == TouchPhase.BEGAN)
{
buttonDown = true;
shape.graphics.moveTo(touch.globalX, touch.globalY);
}
else if ( touch.phase == TouchPhase.ENDED )
{
buttonDown = false;
shape.graphics.lineTo(touch.globalX, touch.globalY);
}
else if ( touch.phase == TouchPhase.MOVED )
{
if ( buttonDown )
shape.graphics.lineTo(touch.globalX, touch.globalY);
}
}
Thank you very much , let me try this code :D
I can't fix this problem. Please update swc file for me
I can't change Stroke.as class in the swc
Thanks
And about Stroke.as 1180: Call to a possibly undefined method setGeometryInvalid.
I can't see method setGeometryInvalid in this class
Hi IonSwitz , I've already loaded all new lib and try to setting again,and It's work !!!! :D
Thank you very much much much hahaha ^____^
I am unable to build the SWC, so I can't upload it, but it seems things worked out? Glad to be of help.
It's work for me, Thank you again :D
Hi IonSwitz,
I've some problem with performance when draw many line on stage. Before draw the line framerate is still 60. But when I've draw line framerate is down from 60 to 10-20
In my code have just 2 shape and each shape just use lineTo and moveTo
How to fix this
Thanks
netzerodash - a framerate drop like that does seem severe, but it depends on so many things it's hard for me to say what the problem might be. Though you only have two shapes, if each shape has large amounts of geometry then a framerate like this may be expected on a low powered device.
Are you clear()'ing and re-drawing each frame? How many lines are you drawing? 10, 100, 1000? What device are you running on?
If you're able to post some sample code that'd be a great help. Running your scene through Scout and spotting where all the performance is going would also help.
jonathanrpace - I want to draw the wheel mark when dragging the touch point. I've used TouchEvent to listen Touch BEGAN , ENDED and MOVED event. And Use EnterFrame to check touch status if began I'll move the starter point with moveTo and then when the user move the touch point , I've draw the line with lineTo
private function setStatus(event:TouchEvent):void
{
//trace("SET STATUS");
touch = event.getTouch(stage);
if(touch)
{
if(touch.phase == TouchPhase.BEGAN)
{
moveStatus = true;
canWrite();
starter(localToGlobal(new Point(wheelL.x+5,wheelL.y-10)),localToGlobal(new Point(wheelR.x+14,wheelR.y-10)));
}
else if(touch.phase == TouchPhase.ENDED)
{
moveStatus = false;
isMove = false;
TweenLite.to(_player,2,{x:touch.globalX,y:touch.globalY});
dontWrite();
}
else if(touch.phase == TouchPhase.MOVED)
{
isMove = true;
}
}
}
private function enterFrameHandler(event:Event):void { //trace(event.type); //trace("isMove : ",isMove," moveStatus : ",moveStatus); pl.x = wheelL.x; pl.y = wheelL.y;
pr.x = wheelR.x;
pr.y = wheelR.y;
if(moveStatus == true)
{
_destinationX = touch.globalX;
_destinationY = touch.globalY;
if(isMove == true)
{
_player.x += (_destinationX - _player.x) / _playerSpeed;
_player.y += (_destinationY - _player.y) / _playerSpeed;
drawLine(new Point(wheelL.x+5,wheelL.y-10),new Point(wheelR.x+14,wheelR.y-25));
}
rotatePlayer();
}
}
Please help me
You have to realize that we do this on our spare time, and that we all have very busy work schedules. We will help you when we can, but you should look into running Scout to determine where your application is running slow. We can't debug the performance of your application for you.
I'm so sorry about that, I'll try to fix it and tell you agian
Thanks
Could you post the bits of drawLine() that use our code?
I'd coding in Flash adobe air for draw the wheel mark when I've use moveTo method in first time and then called the lineTo method, no problem with this step but next step, when I've move the point with moveTo method and called lineTo, it's return an error like this
RangeError: Error #1125: The index 1236 is out of range 1234. at starling.display.graphics::Stroke/addVertex()[/Users/mpz/Documents/Mobile Apps/MyMarketsApp/Starling-Extension-Graphics/src/starling/display/graphics/Stroke.as:88] at starling.display::Graphics/lineTo()[/Users/mpz/Documents/Mobile Apps/MyMarketsApp/Starling-Extension-Graphics/src/starling/display/Graphics.as:415] at Main/drawLine()[/Users/netzerodash/Desktop/AlwaysOn/Flash/BMW/iPad/Main.as:159] at netzerodash.assets::Cars/enterFrameHandler()[/Users/netzerodash/Desktop/AlwaysOn/Flash/BMW/iPad/netzerodash/assets/Cars.as:142] at starling.events::EventDispatcher/invokeEvent()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/events/EventDispatcher.as:141] at starling.events::EventDispatcher/dispatchEvent()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/events/EventDispatcher.as:112] at starling.display::DisplayObjectContainer/broadcastEvent()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/display/DisplayObjectContainer.as:375] at starling.display::Stage/advanceTime()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/display/Stage.as:77] at starling.core::Starling/advanceTime()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/core/Starling.as:380] at starling.core::Starling/nextFrame()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/core/Starling.as:369] at starling.core::Starling/onEnterFrame()[/Users/netzerodash/Develops_Work/Flash/PrimaryFeather-Starling-Framework-1a50854/starling/src/starling/core/Starling.as:568]
How to fix this problem
Thanks