≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Problem with drawn rectangle
Posted by:
(you are not logged in)
Enter the missing letter in: "Int?rnational"
(you are not logged in)
Text:
[quote][b][/b] wrote: [code]function onFrameDrawing() { ccbDrawColoredRectangle(0x35ffffff, Pos2D.x - 30, Pos2D.y - 2, Pos2D.x - 10, Pos2D.y + 2); ccbDrawColoredRectangle(0x35ffffff, Pos2D.x + 10, Pos2D.y - 2, Pos2D.x + 30, Pos2D.y + 2); ccbDrawColoredRectangle(0x35ffffff, Pos2D.x - 2, Pos2D.y + 10, Pos2D.x + 2, Pos2D.y + 30); } ccbRegisterOnFrameEvent(onFrameDrawing); }[/code] This part is not correct.. look how i made it.. right now you have function in a loop and you registrering it every loop.(and that will affect framerate for sure in long run) Should be: [code]/* <behavior jsname="behavior_aim" description="Look how bullet will fly"> <property name="StartPoint" type="scenenode"/> <property name="EndPoint" type="scenenode"/> <property name="Crosshair" type="texture"/> <property name="Crosshair_Size_X" type="float"/> <property name="Crosshair_Size_Y" type="float"/> </behavior> */ Pos2D = 0; behavior_aim = function() { }; behavior_aim.prototype.onAnimate = function() { var SP = ccbGetSceneNodeProperty(this.StartPoint, "PositionAbs"); var EP = ccbGetSceneNodeProperty(this.EndPoint, "PositionAbs"); var Col = ccbGetCollisionPointOfWorldWithLine(SP.x, SP.y, SP.z, EP.x, EP.y, EP.z); if (Col == null) { Pos2D = ccbGet2DPosFrom3DPos(EP.x, EP.y, EP.z); } else if (Col) { Pos2D = ccbGet2DPosFrom3DPos(Col.x, Col.y, Col.z); }; } function onFrameDrawing() { ccbDrawColoredRectangle(0x77ff0000, Pos2D.x - 30, Pos2D.y - 2, Pos2D.x - 10, Pos2D.y + 2); ccbDrawColoredRectangle(0x77ff0000, Pos2D.x + 10, Pos2D.y - 2, Pos2D.x + 30, Pos2D.y + 2); ccbDrawColoredRectangle(0x77ff0000, Pos2D.x - 2, Pos2D.y + 10, Pos2D.x + 2, Pos2D.y + 30); } ccbRegisterOnFrameEvent(onFrameDrawing); [/code][/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact